<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.17"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>QuEST: Unit test utilities</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
                    <a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Unit test utilities</div>  </div>
</div><!--header-->
<div class="contents">

<p>Functions used in the unit testing. These are mostly unoptimised, analytic implementations of the complex linear algebra that QuEST ultimately effects on quantum states. These are not part of the QuEST API, and require C++14.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gabbc686f5f40eff22e08a2b2012ac4e41"><td class="memItemLeft" align="right" valign="top">typedef std::vector&lt; std::vector&lt; <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a> &gt; &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a></td></tr>
<tr class="memdesc:gabbc686f5f40eff22e08a2b2012ac4e41"><td class="mdescLeft">&#160;</td><td class="mdescRight">A complex square matrix.  <a href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">More...</a><br /></td></tr>
<tr class="separator:gabbc686f5f40eff22e08a2b2012ac4e41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac9263a65c96a458b810b20baa81c5b94"><td class="memItemLeft" align="right" valign="top">typedef std::vector&lt; <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a></td></tr>
<tr class="memdesc:gac9263a65c96a458b810b20baa81c5b94"><td class="mdescLeft">&#160;</td><td class="mdescRight">A complex vector, which can be zero-initialised with QVector(numAmps).  <a href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">More...</a><br /></td></tr>
<tr class="separator:gac9263a65c96a458b810b20baa81c5b94"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gacd00096ffcc67d460c204cb833388b0f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gacd00096ffcc67d460c204cb833388b0f">applyReferenceMatrix</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gacd00096ffcc67d460c204cb833388b0f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of left-multiplying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively).  <a href="group__testutilities.html#gacd00096ffcc67d460c204cb833388b0f">More...</a><br /></td></tr>
<tr class="separator:gacd00096ffcc67d460c204cb833388b0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga059fea2ee0415bf25929601ba0788164"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga059fea2ee0415bf25929601ba0788164">applyReferenceMatrix</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga059fea2ee0415bf25929601ba0788164"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of left-multiplying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively).  <a href="group__testutilities.html#ga059fea2ee0415bf25929601ba0788164">More...</a><br /></td></tr>
<tr class="separator:ga059fea2ee0415bf25929601ba0788164"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2b197ca736a01f05bf18fbc5c5a9bee6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga2b197ca736a01f05bf18fbc5c5a9bee6">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga2b197ca736a01f05bf18fbc5c5a9bee6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively).  <a href="group__testutilities.html#ga2b197ca736a01f05bf18fbc5c5a9bee6">More...</a><br /></td></tr>
<tr class="separator:ga2b197ca736a01f05bf18fbc5c5a9bee6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2263bdcb61d571c5ea23d1b6cc5f78cb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga2263bdcb61d571c5ea23d1b6cc5f78cb">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int *ctrls, int numCtrls, int targ1, int targ2, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga2263bdcb61d571c5ea23d1b6cc5f78cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>).  <a href="group__testutilities.html#ga2263bdcb61d571c5ea23d1b6cc5f78cb">More...</a><br /></td></tr>
<tr class="separator:ga2263bdcb61d571c5ea23d1b6cc5f78cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad6816cb8ec41212e2702b04e10de09e8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gad6816cb8ec41212e2702b04e10de09e8">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int *ctrls, int numCtrls, int target, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gad6816cb8ec41212e2702b04e10de09e8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>).  <a href="group__testutilities.html#gad6816cb8ec41212e2702b04e10de09e8">More...</a><br /></td></tr>
<tr class="separator:gad6816cb8ec41212e2702b04e10de09e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac5ee60392d5eb40641862976d7578487"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac5ee60392d5eb40641862976d7578487">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gac5ee60392d5eb40641862976d7578487"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with no control qubits.  <a href="group__testutilities.html#gac5ee60392d5eb40641862976d7578487">More...</a><br /></td></tr>
<tr class="separator:gac5ee60392d5eb40641862976d7578487"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga891d3dc21ce0159754e8084069e6618b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga891d3dc21ce0159754e8084069e6618b">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int ctrl, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga891d3dc21ce0159754e8084069e6618b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with a single control qubit <code>ctrl</code>.  <a href="group__testutilities.html#ga891d3dc21ce0159754e8084069e6618b">More...</a><br /></td></tr>
<tr class="separator:ga891d3dc21ce0159754e8084069e6618b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga93f82b4874355a5df3f052a0bae6e021"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga93f82b4874355a5df3f052a0bae6e021">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int ctrl, int targ, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga93f82b4874355a5df3f052a0bae6e021"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the single-control single-target operator matrix <code>op</code>.  <a href="group__testutilities.html#ga93f82b4874355a5df3f052a0bae6e021">More...</a><br /></td></tr>
<tr class="separator:ga93f82b4874355a5df3f052a0bae6e021"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaea411c5c551f15872bf72592798c6151"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gaea411c5c551f15872bf72592798c6151">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int ctrl, int targ1, int targ2, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gaea411c5c551f15872bf72592798c6151"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with a single control qubit <code>ctrl</code>.  <a href="group__testutilities.html#gaea411c5c551f15872bf72592798c6151">More...</a><br /></td></tr>
<tr class="separator:gaea411c5c551f15872bf72592798c6151"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga74eef70cd0948faa81ea80d0111a2d12"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga74eef70cd0948faa81ea80d0111a2d12">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;state, int targ, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga74eef70cd0948faa81ea80d0111a2d12"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the density matrix <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with no control qubit.  <a href="group__testutilities.html#ga74eef70cd0948faa81ea80d0111a2d12">More...</a><br /></td></tr>
<tr class="separator:ga74eef70cd0948faa81ea80d0111a2d12"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga731c2de4d491629d806a03e0aea2f3a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga731c2de4d491629d806a03e0aea2f3a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively).  <a href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">More...</a><br /></td></tr>
<tr class="separator:ga731c2de4d491629d806a03e0aea2f3a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac49c2a7cb2c041f2ec9fcf65337ada74"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac49c2a7cb2c041f2ec9fcf65337ada74">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int *ctrls, int numCtrls, int targ1, int targ2, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gac49c2a7cb2c041f2ec9fcf65337ada74"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>).  <a href="group__testutilities.html#gac49c2a7cb2c041f2ec9fcf65337ada74">More...</a><br /></td></tr>
<tr class="separator:gac49c2a7cb2c041f2ec9fcf65337ada74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabc5d0ff4b92368b8c095c0246387f52f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gabc5d0ff4b92368b8c095c0246387f52f">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int *ctrls, int numCtrls, int target, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gabc5d0ff4b92368b8c095c0246387f52f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>).  <a href="group__testutilities.html#gabc5d0ff4b92368b8c095c0246387f52f">More...</a><br /></td></tr>
<tr class="separator:gabc5d0ff4b92368b8c095c0246387f52f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga757cf0030f27b9df62789df273bbb1e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga757cf0030f27b9df62789df273bbb1e3">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga757cf0030f27b9df62789df273bbb1e3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with no contorl qubits.  <a href="group__testutilities.html#ga757cf0030f27b9df62789df273bbb1e3">More...</a><br /></td></tr>
<tr class="separator:ga757cf0030f27b9df62789df273bbb1e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga25dbf51127ac7528c7f36f7b84286680"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga25dbf51127ac7528c7f36f7b84286680">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int ctrl, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga25dbf51127ac7528c7f36f7b84286680"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>) This updates <code>state</code> under.  <a href="group__testutilities.html#ga25dbf51127ac7528c7f36f7b84286680">More...</a><br /></td></tr>
<tr class="separator:ga25dbf51127ac7528c7f36f7b84286680"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaadab07060aba3146d82f0c2d1a9cd673"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gaadab07060aba3146d82f0c2d1a9cd673">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int ctrl, int targ, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:gaadab07060aba3146d82f0c2d1a9cd673"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>).  <a href="group__testutilities.html#gaadab07060aba3146d82f0c2d1a9cd673">More...</a><br /></td></tr>
<tr class="separator:gaadab07060aba3146d82f0c2d1a9cd673"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9f194f89bf433b816e4e033eb082b03e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga9f194f89bf433b816e4e033eb082b03e">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int ctrl, int targ1, int targ2, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga9f194f89bf433b816e4e033eb082b03e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>).  <a href="group__testutilities.html#ga9f194f89bf433b816e4e033eb082b03e">More...</a><br /></td></tr>
<tr class="separator:ga9f194f89bf433b816e4e033eb082b03e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga79d4e260c948c347200ba82922777abc"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga79d4e260c948c347200ba82922777abc">applyReferenceOp</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;state, int targ, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op)</td></tr>
<tr class="memdesc:ga79d4e260c948c347200ba82922777abc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with no contorl qubits.  <a href="group__testutilities.html#ga79d4e260c948c347200ba82922777abc">More...</a><br /></td></tr>
<tr class="separator:ga79d4e260c948c347200ba82922777abc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8e8781b9483d2ce7fdac542bb96d1e01"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga8e8781b9483d2ce7fdac542bb96d1e01">areEqual</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> a, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> b)</td></tr>
<tr class="memdesc:ga8e8781b9483d2ce7fdac542bb96d1e01"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the absolute value of the difference between every amplitude in matrices <code>a</code> and <code>b</code> is less than <code>REAL_EPS</code>.  <a href="group__testutilities.html#ga8e8781b9483d2ce7fdac542bb96d1e01">More...</a><br /></td></tr>
<tr class="separator:ga8e8781b9483d2ce7fdac542bb96d1e01"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaef0526d5c35d20ac42befaa3067188d9"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gaef0526d5c35d20ac42befaa3067188d9">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr)</td></tr>
<tr class="memdesc:gaef0526d5c35d20ac42befaa3067188d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of density-matrix <code>qureg</code> to <code>matr</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision.  <a href="group__testutilities.html#gaef0526d5c35d20ac42befaa3067188d9">More...</a><br /></td></tr>
<tr class="separator:gaef0526d5c35d20ac42befaa3067188d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga89c312b37e763aa224a008bea7cc381e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga89c312b37e763aa224a008bea7cc381e">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> precision)</td></tr>
<tr class="memdesc:ga89c312b37e763aa224a008bea7cc381e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of density-matrix <code>qureg</code> to <code>matr</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>.  <a href="group__testutilities.html#ga89c312b37e763aa224a008bea7cc381e">More...</a><br /></td></tr>
<tr class="separator:ga89c312b37e763aa224a008bea7cc381e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga451bbbc6b21cd9c1dbf7a5099edd6077"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga451bbbc6b21cd9c1dbf7a5099edd6077">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec)</td></tr>
<tr class="memdesc:ga451bbbc6b21cd9c1dbf7a5099edd6077"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of state-vector <code>qureg</code> to <code>vec</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision.  <a href="group__testutilities.html#ga451bbbc6b21cd9c1dbf7a5099edd6077">More...</a><br /></td></tr>
<tr class="separator:ga451bbbc6b21cd9c1dbf7a5099edd6077"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga448f07d8e8fbc1bd2fb68c614fecdb4c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga448f07d8e8fbc1bd2fb68c614fecdb4c">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> precision)</td></tr>
<tr class="memdesc:ga448f07d8e8fbc1bd2fb68c614fecdb4c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of state-vector <code>qureg</code> to <code>vec</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>.  <a href="group__testutilities.html#ga448f07d8e8fbc1bd2fb68c614fecdb4c">More...</a><br /></td></tr>
<tr class="separator:ga448f07d8e8fbc1bd2fb68c614fecdb4c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac0737242d0628e61e3b2a9d39ed0acc6"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac0737242d0628e61e3b2a9d39ed0acc6">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg1, <a class="el" href="structQureg.html">Qureg</a> qureg2)</td></tr>
<tr class="memdesc:gac0737242d0628e61e3b2a9d39ed0acc6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision.  <a href="group__testutilities.html#gac0737242d0628e61e3b2a9d39ed0acc6">More...</a><br /></td></tr>
<tr class="separator:gac0737242d0628e61e3b2a9d39ed0acc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5df082edc3f71b08ef8f420d109fa175"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga5df082edc3f71b08ef8f420d109fa175">areEqual</a> (<a class="el" href="structQureg.html">Qureg</a> qureg1, <a class="el" href="structQureg.html">Qureg</a> qureg2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> precision)</td></tr>
<tr class="memdesc:ga5df082edc3f71b08ef8f420d109fa175"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>.  <a href="group__testutilities.html#ga5df082edc3f71b08ef8f420d109fa175">More...</a><br /></td></tr>
<tr class="separator:ga5df082edc3f71b08ef8f420d109fa175"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga45cc399adad2e2a67b0124851189fae5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> a, <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> b)</td></tr>
<tr class="memdesc:ga45cc399adad2e2a67b0124851189fae5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the absolute value of the difference between every amplitude in vectors <code>a</code> and <code>b</code> is less than <code>REAL_EPS</code>.  <a href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">More...</a><br /></td></tr>
<tr class="separator:ga45cc399adad2e2a67b0124851189fae5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7753296a935e1dc1b6dfb98607cd2afa"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga7753296a935e1dc1b6dfb98607cd2afa">areEqual</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *reals, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *imags)</td></tr>
<tr class="memdesc:ga7753296a935e1dc1b6dfb98607cd2afa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns true if the absolute value of the difference between every element in <code>vec</code> and those implied by <code>reals</code> and <code>imags</code>, is less than <code>REAL_EPS</code>.  <a href="group__testutilities.html#ga7753296a935e1dc1b6dfb98607cd2afa">More...</a><br /></td></tr>
<tr class="separator:ga7753296a935e1dc1b6dfb98607cd2afa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2e09685323c6b2312a64daf8c74b12b5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga2e09685323c6b2312a64daf8c74b12b5">bitsets</a> (int numBits)</td></tr>
<tr class="memdesc:ga2e09685323c6b2312a64daf8c74b12b5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every <code>numBits-length</code> bit-set, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention).  <a href="group__testutilities.html#ga2e09685323c6b2312a64daf8c74b12b5">More...</a><br /></td></tr>
<tr class="separator:ga2e09685323c6b2312a64daf8c74b12b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga267884197cf7f1d428021cb12a57360c"><td class="memItemLeft" align="right" valign="top">unsigned int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">calcLog2</a> (long unsigned int res)</td></tr>
<tr class="memdesc:ga267884197cf7f1d428021cb12a57360c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns log2 of numbers which must be gauranteed to be 2^n.  <a href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">More...</a><br /></td></tr>
<tr class="separator:ga267884197cf7f1d428021cb12a57360c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3cf199a7de3bbcb3546503f25be9245a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">getConjugateTranspose</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> a)</td></tr>
<tr class="memdesc:ga3cf199a7de3bbcb3546503f25be9245a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the conjugate transpose of the complex square matrix <code>a</code>.  <a href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">More...</a><br /></td></tr>
<tr class="separator:ga3cf199a7de3bbcb3546503f25be9245a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac60cee26113732c491f21dc43066b605"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac60cee26113732c491f21dc43066b605">getExponentialOfDiagonalMatrix</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> a)</td></tr>
<tr class="memdesc:gac60cee26113732c491f21dc43066b605"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the matrix exponential of a diagonal, square, complex matrix.  <a href="group__testutilities.html#gac60cee26113732c491f21dc43066b605">More...</a><br /></td></tr>
<tr class="separator:gac60cee26113732c491f21dc43066b605"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga00f4feec845c019c3390898b0cc7f1ef"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga00f4feec845c019c3390898b0cc7f1ef">getExponentialOfPauliMatrix</a> (<a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> angle, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> a)</td></tr>
<tr class="memdesc:ga00f4feec845c019c3390898b0cc7f1ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the matrix exponential of a kronecker product of pauli matrices (or of any involutory matrices), with exponent factor (-i <code>angle</code> / 2).  <a href="group__testutilities.html#ga00f4feec845c019c3390898b0cc7f1ef">More...</a><br /></td></tr>
<tr class="separator:ga00f4feec845c019c3390898b0cc7f1ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga20f041452b43026d876fde17a5999265"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">getFullOperatorMatrix</a> (int *ctrls, int numCtrls, int *targs, int numTargs, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> op, int numQubits)</td></tr>
<tr class="memdesc:ga20f041452b43026d876fde17a5999265"><td class="mdescLeft">&#160;</td><td class="mdescRight">Takes a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code> <code>op</code> and a returns a 2^<code>numQubits-by-2^<code>numQubits</code> matrix</code> where <code>op</code> is controlled on the given <code>ctrls</code> qubits.  <a href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">More...</a><br /></td></tr>
<tr class="separator:ga20f041452b43026d876fde17a5999265"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac0c6339c28256f2aae86d443fae44455"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a> (size_t dim)</td></tr>
<tr class="memdesc:gac0c6339c28256f2aae86d443fae44455"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a dim-by-dim identity matrix.  <a href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">More...</a><br /></td></tr>
<tr class="separator:gac0c6339c28256f2aae86d443fae44455"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2de7d3b138728b6beb7753b82df61803"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga2de7d3b138728b6beb7753b82df61803">getKetBra</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> ket, <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> bra)</td></tr>
<tr class="memdesc:ga2de7d3b138728b6beb7753b82df61803"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the matrix |<code>ket&gt;&lt;<code>bra|</code>,</code> with ith-jth element <code>ket(i)</code> conj(<code>bra(j)</code>), since |<code>ket&gt;&lt;<code>bra|</code> =</code> sum_i a_i|i&gt; sum_j b_j* &lt;j| = sum_{ij} a_i b_j* |i&gt;&lt;j|.  <a href="group__testutilities.html#ga2de7d3b138728b6beb7753b82df61803">More...</a><br /></td></tr>
<tr class="separator:ga2de7d3b138728b6beb7753b82df61803"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga50616e813b0d0aa4f8220785d780cdff"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> a, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> b)</td></tr>
<tr class="memdesc:ga50616e813b0d0aa4f8220785d780cdff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the kronecker product of <code>a</code> and <code>b</code>, where <code>a</code> and <code>b</code> are square but possibly differently-sized complex matrices.  <a href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">More...</a><br /></td></tr>
<tr class="separator:ga50616e813b0d0aa4f8220785d780cdff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5438455c2c8ecf5948ca22875313a590"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga5438455c2c8ecf5948ca22875313a590">getNormalised</a> (<a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec)</td></tr>
<tr class="memdesc:ga5438455c2c8ecf5948ca22875313a590"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns an L2-normalised copy of <code>vec</code>, using Kahan summation for improved accuracy.  <a href="group__testutilities.html#ga5438455c2c8ecf5948ca22875313a590">More...</a><br /></td></tr>
<tr class="separator:ga5438455c2c8ecf5948ca22875313a590"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga617b0fd1eb1c395762c937ad3b23e61b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga617b0fd1eb1c395762c937ad3b23e61b">getRandomDensityMatrix</a> (int numQb)</td></tr>
<tr class="memdesc:ga617b0fd1eb1c395762c937ad3b23e61b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a random <code>numQb-by-<code>numQb</code> density</code> matrix, from an undisclosed distribution, in a very mixed state.  <a href="group__testutilities.html#ga617b0fd1eb1c395762c937ad3b23e61b">More...</a><br /></td></tr>
<tr class="separator:ga617b0fd1eb1c395762c937ad3b23e61b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7125d0747a44db58115899727ac5f6be"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga7125d0747a44db58115899727ac5f6be">getRandomInt</a> (int min, int max)</td></tr>
<tr class="memdesc:ga7125d0747a44db58115899727ac5f6be"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a random integer between <code>min</code> (inclusive) and <code>max</code> (exclusive), from the uniform distribution.  <a href="group__testutilities.html#ga7125d0747a44db58115899727ac5f6be">More...</a><br /></td></tr>
<tr class="separator:ga7125d0747a44db58115899727ac5f6be"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0d3b30625e2350a1e837a0b259dd3b18"><td class="memItemLeft" align="right" valign="top">std::vector&lt; <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga0d3b30625e2350a1e837a0b259dd3b18">getRandomKrausMap</a> (int numQb, int numOps)</td></tr>
<tr class="memdesc:ga0d3b30625e2350a1e837a0b259dd3b18"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a random Kraus map of <code>#numOps</code> 2^<code>numQb-by-2^<code>numQb</code> operators</code>, from an undisclosed distribution.  <a href="group__testutilities.html#ga0d3b30625e2350a1e837a0b259dd3b18">More...</a><br /></td></tr>
<tr class="separator:ga0d3b30625e2350a1e837a0b259dd3b18"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa2e8b958e0cba07e01de9f91a5ce3c9c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gaa2e8b958e0cba07e01de9f91a5ce3c9c">getRandomQMatrix</a> (int dim)</td></tr>
<tr class="memdesc:gaa2e8b958e0cba07e01de9f91a5ce3c9c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>dim-by-<code>dim</code> complex</code> matrix, where the real and imaginary value of each element are independently random, under the standard normal distribution (mean 0, standard deviation 1).  <a href="group__testutilities.html#gaa2e8b958e0cba07e01de9f91a5ce3c9c">More...</a><br /></td></tr>
<tr class="separator:gaa2e8b958e0cba07e01de9f91a5ce3c9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga27dc818709394cb31247e26850215f8a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga27dc818709394cb31247e26850215f8a">getRandomQVector</a> (int dim)</td></tr>
<tr class="memdesc:ga27dc818709394cb31247e26850215f8a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>dim-length</code> vector with random complex amplitudes in the square joining {-1-i, 1+i}, of an undisclosed distribution.  <a href="group__testutilities.html#ga27dc818709394cb31247e26850215f8a">More...</a><br /></td></tr>
<tr class="separator:ga27dc818709394cb31247e26850215f8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacd5aadbe10ecdedaa625f85171c0a3cd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a> (<a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> min, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> max)</td></tr>
<tr class="memdesc:gacd5aadbe10ecdedaa625f85171c0a3cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a random real between <code>min</code> (inclusive) and <code>max</code> (exclusive), from the uniform distribution.  <a href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">More...</a><br /></td></tr>
<tr class="separator:gacd5aadbe10ecdedaa625f85171c0a3cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae1d2eb70b50267f8186cbd53e300d94f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gae1d2eb70b50267f8186cbd53e300d94f">getRandomStateVector</a> (int numQb)</td></tr>
<tr class="memdesc:gae1d2eb70b50267f8186cbd53e300d94f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a random <code>numQb-length</code> L2-normalised state-vector from an undisclosed distribution.  <a href="group__testutilities.html#gae1d2eb70b50267f8186cbd53e300d94f">More...</a><br /></td></tr>
<tr class="separator:gae1d2eb70b50267f8186cbd53e300d94f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1a5e9b668716b91dd8527ce00f7500cf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga1a5e9b668716b91dd8527ce00f7500cf">getRandomUnitary</a> (int numQb)</td></tr>
<tr class="memdesc:ga1a5e9b668716b91dd8527ce00f7500cf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a uniformly random (under Haar) 2^<code>numQb-by-2^<code>numQb</code> unitary</code> matrix.  <a href="group__testutilities.html#ga1a5e9b668716b91dd8527ce00f7500cf">More...</a><br /></td></tr>
<tr class="separator:ga1a5e9b668716b91dd8527ce00f7500cf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga37e0f375a6c50721aaf68153f750e842"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga37e0f375a6c50721aaf68153f750e842">getSwapMatrix</a> (int qb1, int qb2, int numQb)</td></tr>
<tr class="memdesc:ga37e0f375a6c50721aaf68153f750e842"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the 2^<code>numQb-by-2^<code>numQb</code> unitary</code> matrix which swaps qubits <code>qb1</code> and <code>qb2</code>; the SWAP gate of not-necessarily-adjacent qubits.  <a href="group__testutilities.html#ga37e0f375a6c50721aaf68153f750e842">More...</a><br /></td></tr>
<tr class="separator:ga37e0f375a6c50721aaf68153f750e842"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6ccbb15b0f234e926be96a153181b63a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a> (size_t dim)</td></tr>
<tr class="memdesc:ga6ccbb15b0f234e926be96a153181b63a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a dim-by-dim square complex matrix, initialised to all zeroes.  <a href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">More...</a><br /></td></tr>
<tr class="separator:ga6ccbb15b0f234e926be96a153181b63a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac102c131efa312dabd5462e6e2642975"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gac102c131efa312dabd5462e6e2642975">pauliseqs</a> (int numPaulis)</td></tr>
<tr class="memdesc:gac102c131efa312dabd5462e6e2642975"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every <code>numPaulis-length</code> set of Pauli-matrix types (or base-4 integers).  <a href="group__testutilities.html#gac102c131efa312dabd5462e6e2642975">More...</a><br /></td></tr>
<tr class="separator:gac102c131efa312dabd5462e6e2642975"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga181366c4cdc7786bcc066e8ac8342c1d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga181366c4cdc7786bcc066e8ac8342c1d">sequences</a> (int base, int numDigits)</td></tr>
<tr class="memdesc:ga181366c4cdc7786bcc066e8ac8342c1d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every <code>numDigits-length</code> sequence in the given <code>base</code>, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention).  <a href="group__testutilities.html#ga181366c4cdc7786bcc066e8ac8342c1d">More...</a><br /></td></tr>
<tr class="separator:ga181366c4cdc7786bcc066e8ac8342c1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafaecff2462bd0b490edff484911d831e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gafaecff2462bd0b490edff484911d831e">setRandomPauliSum</a> (<a class="el" href="structPauliHamil.html">PauliHamil</a> hamil)</td></tr>
<tr class="memdesc:gafaecff2462bd0b490edff484911d831e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Populates <code>hamil</code> with random coefficients and pauli codes.  <a href="group__testutilities.html#gafaecff2462bd0b490edff484911d831e">More...</a><br /></td></tr>
<tr class="separator:gafaecff2462bd0b490edff484911d831e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga11c465ce1a5c238946a9e09d61c94c58"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga11c465ce1a5c238946a9e09d61c94c58">setRandomPauliSum</a> (<a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *codes, int numQubits, int numTerms)</td></tr>
<tr class="memdesc:ga11c465ce1a5c238946a9e09d61c94c58"><td class="mdescLeft">&#160;</td><td class="mdescRight">Populates the <code>coeffs</code> array with random qreals in (-5, 5), and populates <code>codes</code> with random Pauli codes.  <a href="group__testutilities.html#ga11c465ce1a5c238946a9e09d61c94c58">More...</a><br /></td></tr>
<tr class="separator:ga11c465ce1a5c238946a9e09d61c94c58"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga75966a02c618790c1de5f0102ab8398f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;dest, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> sub, size_t r, size_t c)</td></tr>
<tr class="memdesc:ga75966a02c618790c1de5f0102ab8398f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Modifies <code>dest</code> by overwriting its submatrix (from top-left corner (<code>r</code>, <code>c</code>) to bottom-right corner (<code>r</code> + <code>dest.size()</code>, <code>c</code> + <code>dest.size()</code>) with the complete elements of sub.  <a href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">More...</a><br /></td></tr>
<tr class="separator:ga75966a02c618790c1de5f0102ab8398f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab724b72e679a9be95ff5e01b076928df"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gab724b72e679a9be95ff5e01b076928df">sublists</a> (<a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;gen, int numSamps, const int *exclude, int numExclude)</td></tr>
<tr class="memdesc:gab724b72e679a9be95ff5e01b076928df"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code>, which exclude all elements in <code>exclude</code>, in increasing lexographic order.  <a href="group__testutilities.html#gab724b72e679a9be95ff5e01b076928df">More...</a><br /></td></tr>
<tr class="separator:gab724b72e679a9be95ff5e01b076928df"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae479aa71f65fce301d64ed8cd9118e95"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gae479aa71f65fce301d64ed8cd9118e95">sublists</a> (<a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;gen, int numSamps, int excluded)</td></tr>
<tr class="memdesc:gae479aa71f65fce301d64ed8cd9118e95"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code> which exclude element <code>excluded</code>, in increasing lexographic order.  <a href="group__testutilities.html#gae479aa71f65fce301d64ed8cd9118e95">More...</a><br /></td></tr>
<tr class="separator:gae479aa71f65fce301d64ed8cd9118e95"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabe5be8b856a9f67e392db86a62d8cf31"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gabe5be8b856a9f67e392db86a62d8cf31">sublists</a> (<a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;gen, int sublen)</td></tr>
<tr class="memdesc:gabe5be8b856a9f67e392db86a62d8cf31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code>, in increasing lexographic order.  <a href="group__testutilities.html#gabe5be8b856a9f67e392db86a62d8cf31">More...</a><br /></td></tr>
<tr class="separator:gabe5be8b856a9f67e392db86a62d8cf31"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga35add15146aa606b256df79334b867d5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int * &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga35add15146aa606b256df79334b867d5">sublists</a> (int *list, int len, int sublen)</td></tr>
<tr class="memdesc:ga35add15146aa606b256df79334b867d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a Catch2 generator of every length-<code>sublen</code> sublist of length-<code>len</code> <code>list</code>, in increasing lexographic order.  <a href="group__testutilities.html#ga35add15146aa606b256df79334b867d5">More...</a><br /></td></tr>
<tr class="separator:ga35add15146aa606b256df79334b867d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga731a7a71755c25ebe96e742e3fbe5812"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga731a7a71755c25ebe96e742e3fbe5812">toComplexMatrix2</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> qm)</td></tr>
<tr class="memdesc:ga731a7a71755c25ebe96e742e3fbe5812"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code><a class="el" href="structComplexMatrix2.html" title="Represents a 2x2 matrix of complex numbers.">ComplexMatrix2</a></code> copy of QMatix <code>qm</code>.  <a href="group__testutilities.html#ga731a7a71755c25ebe96e742e3fbe5812">More...</a><br /></td></tr>
<tr class="separator:ga731a7a71755c25ebe96e742e3fbe5812"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga216f7c25bbb0cf752d1b6fff5ea8197b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga216f7c25bbb0cf752d1b6fff5ea8197b">toComplexMatrix4</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> qm)</td></tr>
<tr class="memdesc:ga216f7c25bbb0cf752d1b6fff5ea8197b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code><a class="el" href="structComplexMatrix4.html" title="Represents a 4x4 matrix of complex numbers.">ComplexMatrix4</a></code> copy of QMatix <code>qm</code>.  <a href="group__testutilities.html#ga216f7c25bbb0cf752d1b6fff5ea8197b">More...</a><br /></td></tr>
<tr class="separator:ga216f7c25bbb0cf752d1b6fff5ea8197b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7f83695bea7d0332a577bca017dbb03c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga7f83695bea7d0332a577bca017dbb03c">toComplexMatrixN</a> (<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> qm, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> cm)</td></tr>
<tr class="memdesc:ga7f83695bea7d0332a577bca017dbb03c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialises <code>cm</code> with the values of <code>qm</code>.  <a href="group__testutilities.html#ga7f83695bea7d0332a577bca017dbb03c">More...</a><br /></td></tr>
<tr class="separator:ga7f83695bea7d0332a577bca017dbb03c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad552153e13f45cf6c7d6447ae6d9551a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gad552153e13f45cf6c7d6447ae6d9551a">toQMatrix</a> (<a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="memdesc:gad552153e13f45cf6c7d6447ae6d9551a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the matrix (where a=<code>alpha</code>, b=<code>beta</code>) {{a, -conj(b)}, {b, conj(a)}} using the <code>qcomp</code> complex type.  <a href="group__testutilities.html#gad552153e13f45cf6c7d6447ae6d9551a">More...</a><br /></td></tr>
<tr class="separator:gad552153e13f45cf6c7d6447ae6d9551a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga253946523907014c4f198d2bb38d4913"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga253946523907014c4f198d2bb38d4913">toQMatrix</a> (<a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> src)</td></tr>
<tr class="memdesc:ga253946523907014c4f198d2bb38d4913"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a copy of the given 2-by-2 matrix.  <a href="group__testutilities.html#ga253946523907014c4f198d2bb38d4913">More...</a><br /></td></tr>
<tr class="separator:ga253946523907014c4f198d2bb38d4913"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3dbd53326151e3c6c5e0de579f6554a7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga3dbd53326151e3c6c5e0de579f6554a7">toQMatrix</a> (<a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> src)</td></tr>
<tr class="memdesc:ga3dbd53326151e3c6c5e0de579f6554a7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a copy of the given 4-by-4 matrix.  <a href="group__testutilities.html#ga3dbd53326151e3c6c5e0de579f6554a7">More...</a><br /></td></tr>
<tr class="separator:ga3dbd53326151e3c6c5e0de579f6554a7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadbcd76cb251c802e7f81803bdd23064b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gadbcd76cb251c802e7f81803bdd23064b">toQMatrix</a> (<a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> src)</td></tr>
<tr class="memdesc:gadbcd76cb251c802e7f81803bdd23064b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a copy of the given 2^<code>N-by-2^<code>N</code> matrix</code>.  <a href="group__testutilities.html#gadbcd76cb251c802e7f81803bdd23064b">More...</a><br /></td></tr>
<tr class="separator:gadbcd76cb251c802e7f81803bdd23064b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga95a4a8d36ad12018f5ffe92f39f4cfb8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga95a4a8d36ad12018f5ffe92f39f4cfb8">toQMatrix</a> (<a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="memdesc:ga95a4a8d36ad12018f5ffe92f39f4cfb8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a 2^<code>N-by-2^<code>N</code> complex</code> diagonal matrix form of the <a class="el" href="structDiagonalOp.html" title="Represents a diagonal complex operator on the full Hilbert state of a Qureg.">DiagonalOp</a>.  <a href="group__testutilities.html#ga95a4a8d36ad12018f5ffe92f39f4cfb8">More...</a><br /></td></tr>
<tr class="separator:ga95a4a8d36ad12018f5ffe92f39f4cfb8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae1131c2c5e1a36b5b6e2b614c6d7cdc8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gae1131c2c5e1a36b5b6e2b614c6d7cdc8">toQMatrix</a> (<a class="el" href="structPauliHamil.html">PauliHamil</a> hamil)</td></tr>
<tr class="memdesc:gae1131c2c5e1a36b5b6e2b614c6d7cdc8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a 2^<code>N-by-2^<code>N</code> Hermitian</code> matrix form of the <a class="el" href="structPauliHamil.html" title="Represents a weighted sum of pauli products.">PauliHamil</a>.  <a href="group__testutilities.html#gae1131c2c5e1a36b5b6e2b614c6d7cdc8">More...</a><br /></td></tr>
<tr class="separator:gae1131c2c5e1a36b5b6e2b614c6d7cdc8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga29dd7da2b0f2104a90c88fb081e67a0e"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga29dd7da2b0f2104a90c88fb081e67a0e">toQMatrix</a> (<a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *coeffs, <a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *paulis, int numQubits, int numTerms)</td></tr>
<tr class="memdesc:ga29dd7da2b0f2104a90c88fb081e67a0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a 2^<code>N-by-2^<code>N</code> Hermitian</code> matrix form of the specified weighted sum of Pauli products.  <a href="group__testutilities.html#ga29dd7da2b0f2104a90c88fb081e67a0e">More...</a><br /></td></tr>
<tr class="separator:ga29dd7da2b0f2104a90c88fb081e67a0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4c4ce1767ee2ef420c0078ea5991aeb0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga4c4ce1767ee2ef420c0078ea5991aeb0">toQMatrix</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:ga4c4ce1767ee2ef420c0078ea5991aeb0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns an equal-size copy of the given density matrix <code>qureg</code>.  <a href="group__testutilities.html#ga4c4ce1767ee2ef420c0078ea5991aeb0">More...</a><br /></td></tr>
<tr class="separator:ga4c4ce1767ee2ef420c0078ea5991aeb0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5e1bcff9f5867273c4d413a60dc78e8e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga5e1bcff9f5867273c4d413a60dc78e8e">toQureg</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> mat)</td></tr>
<tr class="memdesc:ga5e1bcff9f5867273c4d413a60dc78e8e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialises the density matrix <code>qureg</code> to have the same amplitudes as <code>mat</code>.  <a href="group__testutilities.html#ga5e1bcff9f5867273c4d413a60dc78e8e">More...</a><br /></td></tr>
<tr class="separator:ga5e1bcff9f5867273c4d413a60dc78e8e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf5a18d4c00dfe0523972be3bfc666362"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gaf5a18d4c00dfe0523972be3bfc666362">toQureg</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec)</td></tr>
<tr class="memdesc:gaf5a18d4c00dfe0523972be3bfc666362"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialises the state-vector <code>qureg</code> to have the same amplitudes as <code>vec</code>.  <a href="group__testutilities.html#gaf5a18d4c00dfe0523972be3bfc666362">More...</a><br /></td></tr>
<tr class="separator:gaf5a18d4c00dfe0523972be3bfc666362"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga09f18ab46d2b17ad13185c0b4c06b400"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#ga09f18ab46d2b17ad13185c0b4c06b400">toQVector</a> (<a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="memdesc:ga09f18ab46d2b17ad13185c0b4c06b400"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a vector with the same of the full diagonal operator, populated with <code>op's</code> elements.  <a href="group__testutilities.html#ga09f18ab46d2b17ad13185c0b4c06b400">More...</a><br /></td></tr>
<tr class="separator:ga09f18ab46d2b17ad13185c0b4c06b400"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gade0e7c37811a69f1c21c88c11943a19f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__testutilities.html#gade0e7c37811a69f1c21c88c11943a19f">toQVector</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="memdesc:gade0e7c37811a69f1c21c88c11943a19f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns an equal-size copy of the given state-vector <code>qureg</code>.  <a href="group__testutilities.html#gade0e7c37811a69f1c21c88c11943a19f">More...</a><br /></td></tr>
<tr class="separator:gade0e7c37811a69f1c21c88c11943a19f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Functions used in the unit testing. These are mostly unoptimised, analytic implementations of the complex linear algebra that QuEST ultimately effects on quantum states. These are not part of the QuEST API, and require C++14. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gabbc686f5f40eff22e08a2b2012ac4e41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabbc686f5f40eff22e08a2b2012ac4e41">&#9670;&nbsp;</a></span>QMatrix</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::vector&lt;std::vector&lt;<a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>&gt; &gt; <a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A complex square matrix. </p>
<p>Should be initialised with <a class="el" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a" title="Returns a dim-by-dim square complex matrix, initialised to all zeroes.">getZeroMatrix()</a>. These have all the natural linear-algebra operator overloads, including left-multiplication onto a vector.</p>
<p>This data-structure is not partitioned between nodes in distributed mode. That is, every node has a complete copy, allowing for safe comparisons.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8hpp_source.html#l00049">49</a> of file <a class="el" href="utilities_8hpp_source.html">utilities.hpp</a>.</p>

</div>
</div>
<a id="gac9263a65c96a458b810b20baa81c5b94"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac9263a65c96a458b810b20baa81c5b94">&#9670;&nbsp;</a></span>QVector</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef std::vector&lt;<a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>&gt; <a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A complex vector, which can be zero-initialised with QVector(numAmps). </p>
<p>These have all the natural linear-algebra operator overloads.</p>
<p>This data-structure is not partitioned between nodes in distributed mode. That is, every node has a complete copy, allowing for safe comparisons.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8hpp_source.html#l00060">60</a> of file <a class="el" href="utilities_8hpp_source.html">utilities.hpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gacd00096ffcc67d460c204cb833388b0f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacd00096ffcc67d460c204cb833388b0f">&#9670;&nbsp;</a></span>applyReferenceMatrix() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of left-multiplying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively). </p>
<p>Here, <code>op</code> is treated like a simple matrix and is hence left-multiplied onto the state once.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00692">692</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00694"></a><span class="lineno">  694</span>&#160;  {</div>
<div class="line"><a name="l00695"></a><span class="lineno">  695</span>&#160;    <span class="comment">// for density matrices, op is left-multiplied only</span></div>
<div class="line"><a name="l00696"></a><span class="lineno">  696</span>&#160;    <span class="keywordtype">int</span> numQubits = <a class="code" href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">calcLog2</a>(state.size());</div>
<div class="line"><a name="l00697"></a><span class="lineno">  697</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> leftOp = <a class="code" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">getFullOperatorMatrix</a>(ctrls, numCtrls, targs, numTargs, op, numQubits);</div>
<div class="line"><a name="l00698"></a><span class="lineno">  698</span>&#160;    state = leftOp * state;</div>
<div class="line"><a name="l00699"></a><span class="lineno">  699</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00361">calcLog2()</a>, and <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>.</p>

</div>
</div>
<a id="ga059fea2ee0415bf25929601ba0788164"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga059fea2ee0415bf25929601ba0788164">&#9670;&nbsp;</a></span>applyReferenceMatrix() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of left-multiplying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively). </p>
<p>This is an alias of <a class="el" href="group__testutilities.html#ga2b197ca736a01f05bf18fbc5c5a9bee6" title="Modifies the density matrix state to be the result of applying the multi-target operator matrix op,...">applyReferenceOp()</a>, since operators are always left-multiplied as matrices onto state-vectors.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00686">686</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160;  {</div>
<div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;    <span class="comment">// for state-vectors, the op is always just left-multiplied</span></div>
<div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, numCtrls, targs, numTargs, op);</div>
<div class="line"><a name="l00691"></a><span class="lineno">  691</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__operators_8cpp_source.html#l00085">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga2b197ca736a01f05bf18fbc5c5a9bee6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2b197ca736a01f05bf18fbc5c5a9bee6">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[1/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>. Furthermore, every element of <code>targs</code> must not appear in <code>ctrls</code> (and vice-versa), though this is not explicitly checked. Elements of <code>targs</code> and <code>ctrls</code> should be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00629">629</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00631"></a><span class="lineno">  631</span>&#160;  {</div>
<div class="line"><a name="l00632"></a><span class="lineno">  632</span>&#160;    <span class="keywordtype">int</span> numQubits = <a class="code" href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">calcLog2</a>(state.size());</div>
<div class="line"><a name="l00633"></a><span class="lineno">  633</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> leftOp = <a class="code" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">getFullOperatorMatrix</a>(ctrls, numCtrls, targs, numTargs, op, numQubits);</div>
<div class="line"><a name="l00634"></a><span class="lineno">  634</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> rightOp = <a class="code" href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">getConjugateTranspose</a>(leftOp);</div>
<div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;    state = leftOp * state * rightOp;</div>
<div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00361">calcLog2()</a>, <a class="el" href="utilities_8cpp_source.html#l00179">getConjugateTranspose()</a>, and <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>.</p>

</div>
</div>
<a id="ga2263bdcb61d571c5ea23d1b6cc5f78cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2263bdcb61d571c5ea23d1b6cc5f78cb">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[2/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 4-by-4 matrix. Both <code>targ1</code> and <code>targ2</code> must not appear in <code>ctrls</code>, though this is not explicitly checked. Elements of <code>ctrls</code>, and <code>targ1</code> and <code>targ2</code>, should be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00637">637</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00639"></a><span class="lineno">  639</span>&#160;  {</div>
<div class="line"><a name="l00640"></a><span class="lineno">  640</span>&#160;    <span class="keywordtype">int</span> targs[2] = {targ1, targ2};</div>
<div class="line"><a name="l00641"></a><span class="lineno">  641</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, numCtrls, targs, 2, op);</div>
<div class="line"><a name="l00642"></a><span class="lineno">  642</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="gad6816cb8ec41212e2702b04e10de09e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad6816cb8ec41212e2702b04e10de09e8">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[3/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2-by-2 matrix. <code>target</code> must not appear in <code>ctrls</code>, though this is not explicitly checked.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00643">643</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;  {</div>
<div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;    <span class="keywordtype">int</span> targs[1] = {target};</div>
<div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, numCtrls, targs, 1, op);</div>
<div class="line"><a name="l00648"></a><span class="lineno">  648</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="gac5ee60392d5eb40641862976d7578487"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac5ee60392d5eb40641862976d7578487">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[4/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with no control qubits. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>. Every element in <code>targs</code> should be unique, though this is not explicitly checked.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00649">649</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00651"></a><span class="lineno">  651</span>&#160;  {</div>
<div class="line"><a name="l00652"></a><span class="lineno">  652</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, NULL, 0, targs, numTargs, op);</div>
<div class="line"><a name="l00653"></a><span class="lineno">  653</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga891d3dc21ce0159754e8084069e6618b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga891d3dc21ce0159754e8084069e6618b">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[5/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with a single control qubit <code>ctrl</code>. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>, and <code>ctrl</code> must not appear in <code>targs</code> (though this is not explicitly checked).</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00661">661</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;  {</div>
<div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, numTargs, op);</div>
<div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga93f82b4874355a5df3f052a0bae6e021"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga93f82b4874355a5df3f052a0bae6e021">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[6/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the single-control single-target operator matrix <code>op</code>. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2-by-2 matrix, and <code>ctrl</code> and <code>targ</code> should be different.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00654">654</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;  {</div>
<div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;    <span class="keywordtype">int</span> targs[1] = {targ};</div>
<div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, 1, op);</div>
<div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="gaea411c5c551f15872bf72592798c6151"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaea411c5c551f15872bf72592798c6151">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[7/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with a single control qubit <code>ctrl</code>. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 4-by-4 matrix, and <code>ctrl</code>, <code>targ1</code> and <code>targ2</code> must be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00667">667</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;  {</div>
<div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00671"></a><span class="lineno">  671</span>&#160;    <span class="keywordtype">int</span> targs[2] = {targ1, targ2};</div>
<div class="line"><a name="l00672"></a><span class="lineno">  672</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, 2, op);</div>
<div class="line"><a name="l00673"></a><span class="lineno">  673</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga74eef70cd0948faa81ea80d0111a2d12"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga74eef70cd0948faa81ea80d0111a2d12">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[8/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the density matrix <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with no control qubit. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \, \text{op}^\dagger \]" src="form_168.png"/>
</p>
<p> even if <code>op</code> is not unitary (which is useful for applying Kraus operators).</p>
<p><code>op</code> must be a 2-by-2 matrix.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multipling it to <code>state</code>, then right-multiplying its conjugate transpose onto the result.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00674">674</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00676"></a><span class="lineno">  676</span>&#160;  {</div>
<div class="line"><a name="l00677"></a><span class="lineno">  677</span>&#160;    <span class="keywordtype">int</span> targs[1] = {targ};</div>
<div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, NULL, 0, targs, 1, op);</div>
<div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga731c2de4d491629d806a03e0aea2f3a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga731c2de4d491629d806a03e0aea2f3a3">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[9/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with the specified control and target qubits (in <code>ctrls</code> and <code>targs</code> respectively). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>. Furthermore, every element of <code>targs</code> must not appear in <code>ctrls</code> (and vice-versa), though this is not explicitly checked. Elements of <code>targs</code> and <code>ctrls</code> should be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00573">573</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;  {</div>
<div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;    <span class="keywordtype">int</span> numQubits = <a class="code" href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">calcLog2</a>(state.size());</div>
<div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> fullOp = <a class="code" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">getFullOperatorMatrix</a>(ctrls, numCtrls, targs, numTargs, op, numQubits);</div>
<div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;    state = fullOp * state;</div>
<div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00361">calcLog2()</a>, and <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00686">applyReferenceMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00580">applyReferenceOp()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gac49c2a7cb2c041f2ec9fcf65337ada74"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac49c2a7cb2c041f2ec9fcf65337ada74">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[10/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 4-by-4 matrix. Furthermore, <code>ctrls</code>, <code>targ1</code> and <code>targ2</code> should all be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00580">580</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160;  {</div>
<div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;    <span class="keywordtype">int</span> targs[2] = {targ1, targ2};</div>
<div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, numCtrls, targs, 2, op);</div>
<div class="line"><a name="l00585"></a><span class="lineno">  585</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="gabc5d0ff4b92368b8c095c0246387f52f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabc5d0ff4b92368b8c095c0246387f52f">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[11/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with the specified control qubits (in <code>ctrls</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2-by-2 matrix. Furthermore, elements in <code>ctrls</code> and <code>target</code> should all be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00586">586</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00588"></a><span class="lineno">  588</span>&#160;  {</div>
<div class="line"><a name="l00589"></a><span class="lineno">  589</span>&#160;    <span class="keywordtype">int</span> targs[1] = {target};</div>
<div class="line"><a name="l00590"></a><span class="lineno">  590</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, numCtrls, targs, 1, op);</div>
<div class="line"><a name="l00591"></a><span class="lineno">  591</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga757cf0030f27b9df62789df273bbb1e3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga757cf0030f27b9df62789df273bbb1e3">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[12/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with no contorl qubits. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>. Furthermore, elements in <code>targs</code> should be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00592">592</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00594"></a><span class="lineno">  594</span>&#160;  {</div>
<div class="line"><a name="l00595"></a><span class="lineno">  595</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, NULL, 0, targs, numTargs, op);</div>
<div class="line"><a name="l00596"></a><span class="lineno">  596</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga25dbf51127ac7528c7f36f7b84286680"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga25dbf51127ac7528c7f36f7b84286680">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[13/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the multi-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>) This updates <code>state</code> under. </p>
<p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code>. Furthermore, elements in <code>targs</code> and <code>ctrl</code> should be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00604">604</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00606"></a><span class="lineno">  606</span>&#160;  {</div>
<div class="line"><a name="l00607"></a><span class="lineno">  607</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00608"></a><span class="lineno">  608</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, numTargs, op);</div>
<div class="line"><a name="l00609"></a><span class="lineno">  609</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="gaadab07060aba3146d82f0c2d1a9cd673"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaadab07060aba3146d82f0c2d1a9cd673">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[14/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2-by-2 matrix. Furthermore, <code>ctrl</code> and <code>targ</code> must be different.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00597">597</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00599"></a><span class="lineno">  599</span>&#160;  {</div>
<div class="line"><a name="l00600"></a><span class="lineno">  600</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00601"></a><span class="lineno">  601</span>&#160;    <span class="keywordtype">int</span> targs[1] = {targ};</div>
<div class="line"><a name="l00602"></a><span class="lineno">  602</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, 1, op);</div>
<div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga9f194f89bf433b816e4e033eb082b03e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9f194f89bf433b816e4e033eb082b03e">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[15/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ctrl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the two-target operator matrix <code>op</code>, with a single control qubit (<code>ctrl</code>). </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 4-by-4 matrix. Furthermore, <code>ctrl</code>, <code>targ1</code> and <code>targ2</code> should all be unique.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00610">610</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00612"></a><span class="lineno">  612</span>&#160;  {</div>
<div class="line"><a name="l00613"></a><span class="lineno">  613</span>&#160;    <span class="keywordtype">int</span> ctrls[1] = {ctrl};</div>
<div class="line"><a name="l00614"></a><span class="lineno">  614</span>&#160;    <span class="keywordtype">int</span> targs[2] = {targ1, targ2};</div>
<div class="line"><a name="l00615"></a><span class="lineno">  615</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, ctrls, 1, targs, 2, op);</div>
<div class="line"><a name="l00616"></a><span class="lineno">  616</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga79d4e260c948c347200ba82922777abc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga79d4e260c948c347200ba82922777abc">&#9670;&nbsp;</a></span>applyReferenceOp() <span class="overload">[16/16]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void applyReferenceOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> &amp;&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targ</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies the state-vector <code>state</code> to be the result of applying the single-target operator matrix <code>op</code>, with no contorl qubits. </p>
<p>This updates <code>state</code> under </p><p class="formulaDsp">
<img class="formulaDsp" alt="\[ \text{state} \to \text{op} \, \text{state} \]" src="form_169.png"/>
</p>
<p> even if <code>op</code> is not unitary.</p>
<p><code>op</code> must be a 2-by-2 matrix.</p>
<p>This function works by computing <a class="el" href="group__testutilities.html#ga20f041452b43026d876fde17a5999265" title="Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...">getFullOperatorMatrix()</a> from the given arguments, and left-multiplying it onto <code>state</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00617">617</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00619"></a><span class="lineno">  619</span>&#160;  {</div>
<div class="line"><a name="l00620"></a><span class="lineno">  620</span>&#160;    <span class="keywordtype">int</span> targs[1] = {targ};</div>
<div class="line"><a name="l00621"></a><span class="lineno">  621</span>&#160;    <a class="code" href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a>(state, NULL, 0, targs, 1, op);</div>
<div class="line"><a name="l00622"></a><span class="lineno">  622</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>.</p>

</div>
</div>
<a id="ga8e8781b9483d2ce7fdac542bb96d1e01"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8e8781b9483d2ce7fdac542bb96d1e01">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[1/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns true if the absolute value of the difference between every amplitude in matrices <code>a</code> and <code>b</code> is less than <code>REAL_EPS</code>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00396">396</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;                                    {</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( a.size() == b.size() );</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;    </div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;a.size(); i++)</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;b.size(); j++)</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;            <span class="keywordflow">if</span> (abs(a[i][j] - b[i][j]) &gt; REAL_EPS)</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>.</p>

</div>
</div>
<a id="gaef0526d5c35d20ac42befaa3067188d9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaef0526d5c35d20ac42befaa3067188d9">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[2/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>matr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of density-matrix <code>qureg</code> to <code>matr</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. </p>
<p>This function demands <code>qureg</code> is a density matrix, and that <code>qureg</code> and <code>matr</code> have equal dimensions.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00819">819</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;                                         {</div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(qureg, matr, REAL_EPS);</div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00387">areEqual()</a>.</p>

</div>
</div>
<a id="ga89c312b37e763aa224a008bea7cc381e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga89c312b37e763aa224a008bea7cc381e">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[3/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>matr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>precision</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of density-matrix <code>qureg</code> to <code>matr</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>. </p>
<p>This function demands <code>qureg</code> is a density matrix, and that <code>qureg</code> and <code>matr</code> have equal dimensions.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00767">767</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00767"></a><span class="lineno">  767</span>&#160;                                                          {</div>
<div class="line"><a name="l00768"></a><span class="lineno">  768</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l00769"></a><span class="lineno">  769</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( (<span class="keywordtype">int</span>) (matr.size()*matr.size()) == qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> );</div>
<div class="line"><a name="l00770"></a><span class="lineno">  770</span>&#160;    </div>
<div class="line"><a name="l00771"></a><span class="lineno">  771</span>&#160;    <span class="comment">// ensure local qureg.stateVec is up to date</span></div>
<div class="line"><a name="l00772"></a><span class="lineno">  772</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160;    </div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    <span class="comment">// the starting index in vec of this node&#39;s qureg partition.</span></div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> startInd = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00777"></a><span class="lineno">  777</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalInd, row, col, i;</div>
<div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;    <span class="keywordtype">int</span> ampsAgree;</div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;    </div>
<div class="line"><a name="l00780"></a><span class="lineno">  780</span>&#160;    <span class="comment">// compare each of this node&#39;s amplitude to the corresponding matr sub-matrix</span></div>
<div class="line"><a name="l00781"></a><span class="lineno">  781</span>&#160;    <span class="keywordflow">for</span> (i=0; i&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; i++) {</div>
<div class="line"><a name="l00782"></a><span class="lineno">  782</span>&#160;        globalInd = startInd + i;</div>
<div class="line"><a name="l00783"></a><span class="lineno">  783</span>&#160;        row = globalInd % matr.size();</div>
<div class="line"><a name="l00784"></a><span class="lineno">  784</span>&#160;        col = globalInd / matr.size();</div>
<div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> realDif = absReal(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] - real(matr[row][col]));</div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> imagDif = absReal(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] - imag(matr[row][col]));</div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;        ampsAgree = (realDif &lt; precision &amp;&amp; imagDif &lt; precision);</div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;        </div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;        <span class="comment">// DEBUG</span></div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;        <span class="keywordflow">if</span> (!ampsAgree) {</div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;            printf(<span class="stringliteral">&quot;[msg from utilities.cpp] node %d has a disagreement at (global) index %lld of (%g) + i(%g)\n&quot;</span>, </div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160;                qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, globalInd, realDif, imagDif</div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;            );</div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;        }</div>
<div class="line"><a name="l00795"></a><span class="lineno">  795</span>&#160; </div>
<div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;        <span class="comment">// break loop as soon as amplitudes disagree</span></div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160;        <span class="keywordflow">if</span> (!ampsAgree)</div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;            <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;            </div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160;        <span class="comment">/* TODO:</span></div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;<span class="comment">         * of the nodes which disagree, the lowest-rank should send its </span></div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;<span class="comment">         * disagreeing (i, row, col, stateVec[i]) to rank 0 which should </span></div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;<span class="comment">         * report it immediately (before the impending DEMAND failure)</span></div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;<span class="comment">         * using FAIL_CHECK, so users can determine nature of disagreement </span></div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;<span class="comment">         * (e.g. numerical precision).</span></div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;<span class="comment">         * Note FAIL_CHECK accepts &lt;&lt; like cout, e.g.</span></div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160;<span class="comment">         * FAIL_CHECK( &quot;Amp at (&quot; &lt;&lt; row &lt;&lt; &quot;, &quot; &lt;&lt; col &quot;) disagreed&quot; );</span></div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;<span class="comment">         */</span></div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160;    }</div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;    </div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;    <span class="comment">// if one node&#39;s partition wasn&#39;t equal, all-nodes must report not-equal</span></div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;    <span class="keywordtype">int</span> allAmpsAgree = ampsAgree;</div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;    MPI_Allreduce(&amp;ampsAgree, &amp;allAmpsAgree, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;        </div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;    <span class="keywordflow">return</span> allAmpsAgree;</div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00039">copyStateFromGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

</div>
</div>
<a id="ga451bbbc6b21cd9c1dbf7a5099edd6077"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga451bbbc6b21cd9c1dbf7a5099edd6077">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[4/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>vec</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of state-vector <code>qureg</code> to <code>vec</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. </p>
<p>This function demands <code>qureg</code> is a state-vector, and that <code>qureg</code> and <code>vec</code> have the same number of amplitudes.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00763">763</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00763"></a><span class="lineno">  763</span>&#160;                                        {</div>
<div class="line"><a name="l00764"></a><span class="lineno">  764</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(qureg, vec, REAL_EPS);</div>
<div class="line"><a name="l00765"></a><span class="lineno">  765</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00387">areEqual()</a>.</p>

</div>
</div>
<a id="ga448f07d8e8fbc1bd2fb68c614fecdb4c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga448f07d8e8fbc1bd2fb68c614fecdb4c">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[5/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>precision</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of state-vector <code>qureg</code> to <code>vec</code>, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>. </p>
<p>This function demands <code>qureg</code> is a state-vector, and that <code>qureg</code> and <code>vec</code> have the same number of amplitudes.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00728">728</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00728"></a><span class="lineno">  728</span>&#160;                                                         {</div>
<div class="line"><a name="l00729"></a><span class="lineno">  729</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( !qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l00730"></a><span class="lineno">  730</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( (<span class="keywordtype">int</span>) vec.size() == qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> );</div>
<div class="line"><a name="l00731"></a><span class="lineno">  731</span>&#160;    </div>
<div class="line"><a name="l00732"></a><span class="lineno">  732</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line"><a name="l00733"></a><span class="lineno">  733</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l00734"></a><span class="lineno">  734</span>&#160;    </div>
<div class="line"><a name="l00735"></a><span class="lineno">  735</span>&#160;    <span class="comment">// the starting index in vec of this node&#39;s qureg partition.</span></div>
<div class="line"><a name="l00736"></a><span class="lineno">  736</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> startInd = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00737"></a><span class="lineno">  737</span>&#160;            </div>
<div class="line"><a name="l00738"></a><span class="lineno">  738</span>&#160;    <span class="keywordtype">int</span> ampsAgree = 1;</div>
<div class="line"><a name="l00739"></a><span class="lineno">  739</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> i=0; i&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; i++) {</div>
<div class="line"><a name="l00740"></a><span class="lineno">  740</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> realDif = absReal(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] - real(vec[startInd+i]));</div>
<div class="line"><a name="l00741"></a><span class="lineno">  741</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> imagDif = absReal(qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] - imag(vec[startInd+i]));</div>
<div class="line"><a name="l00742"></a><span class="lineno">  742</span>&#160; </div>
<div class="line"><a name="l00743"></a><span class="lineno">  743</span>&#160;        <span class="keywordflow">if</span> (realDif &gt; precision || imagDif &gt; precision) {</div>
<div class="line"><a name="l00744"></a><span class="lineno">  744</span>&#160;            ampsAgree = 0;</div>
<div class="line"><a name="l00745"></a><span class="lineno">  745</span>&#160;            </div>
<div class="line"><a name="l00746"></a><span class="lineno">  746</span>&#160;            <span class="comment">// debug</span></div>
<div class="line"><a name="l00747"></a><span class="lineno">  747</span>&#160;            printf(<span class="stringliteral">&quot;Disagreement at %lld: %g + i(%g) VS %g + i(%g)\n&quot;</span>,</div>
<div class="line"><a name="l00748"></a><span class="lineno">  748</span>&#160;                startInd+i, qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i], qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i],</div>
<div class="line"><a name="l00749"></a><span class="lineno">  749</span>&#160;                real(vec[startInd+i]), imag(vec[startInd+i]));</div>
<div class="line"><a name="l00750"></a><span class="lineno">  750</span>&#160;            </div>
<div class="line"><a name="l00751"></a><span class="lineno">  751</span>&#160;            <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00752"></a><span class="lineno">  752</span>&#160;        }</div>
<div class="line"><a name="l00753"></a><span class="lineno">  753</span>&#160;    }</div>
<div class="line"><a name="l00754"></a><span class="lineno">  754</span>&#160;            </div>
<div class="line"><a name="l00755"></a><span class="lineno">  755</span>&#160;    <span class="comment">// if one node&#39;s partition wasn&#39;t equal, all-nodes must report not-equal</span></div>
<div class="line"><a name="l00756"></a><span class="lineno">  756</span>&#160;    <span class="keywordtype">int</span> allAmpsAgree = ampsAgree;</div>
<div class="line"><a name="l00757"></a><span class="lineno">  757</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00758"></a><span class="lineno">  758</span>&#160;    MPI_Allreduce(&amp;ampsAgree, &amp;allAmpsAgree, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00759"></a><span class="lineno">  759</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00760"></a><span class="lineno">  760</span>&#160;    </div>
<div class="line"><a name="l00761"></a><span class="lineno">  761</span>&#160;    <span class="keywordflow">return</span> allAmpsAgree;</div>
<div class="line"><a name="l00762"></a><span class="lineno">  762</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00039">copyStateFromGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

</div>
</div>
<a id="gac0737242d0628e61e3b2a9d39ed0acc6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac0737242d0628e61e3b2a9d39ed0acc6">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[6/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than the QuEST_PREC-specific REAL_EPS (defined in QuEST_precision) precision. </p>
<p>This function demands that <code>qureg1</code> and <code>qureg2</code> are of the same type (i.e. both state-vectors or both density matrices), and of an equal number of qubits.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00724">724</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00724"></a><span class="lineno">  724</span>&#160;                                          {</div>
<div class="line"><a name="l00725"></a><span class="lineno">  725</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(qureg1, qureg2, REAL_EPS);</div>
<div class="line"><a name="l00726"></a><span class="lineno">  726</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00387">areEqual()</a>.</p>

</div>
</div>
<a id="ga5df082edc3f71b08ef8f420d109fa175"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5df082edc3f71b08ef8f420d109fa175">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[7/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>precision</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs a hardware-agnostic comparison of the given quregs, checking whether the difference between the real and imaginary components of every amplitude is smaller than <code>precision</code>. </p>
<p>This function demands that <code>qureg1</code> and <code>qureg2</code> are of the same type (i.e. both state-vectors or both density matrices), and of an equal number of qubits.</p>
<p>In GPU mode, this function involves a GPU to CPU memory copy overhead. In distributed mode, it involves a all-to-all single-int broadcast.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00701">701</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00701"></a><span class="lineno">  701</span>&#160;                                                           {</div>
<div class="line"><a name="l00702"></a><span class="lineno">  702</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg1.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> == qureg2.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l00703"></a><span class="lineno">  703</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg1.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> == qureg2.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> );</div>
<div class="line"><a name="l00704"></a><span class="lineno">  704</span>&#160;        </div>
<div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg1);</div>
<div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg2);</div>
<div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l00708"></a><span class="lineno">  708</span>&#160;    </div>
<div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;    <span class="comment">// loop terminates when areEqual = 0</span></div>
<div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;    <span class="keywordtype">int</span> ampsAgree = 1;</div>
<div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> i=0; ampsAgree &amp;&amp; i&lt;qureg1.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; i++)</div>
<div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;        ampsAgree = (</div>
<div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160;               absReal(qureg1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] - qureg2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i]) &lt; precision</div>
<div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;            &amp;&amp; absReal(qureg1.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] - qureg2.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i]) &lt; precision);</div>
<div class="line"><a name="l00715"></a><span class="lineno">  715</span>&#160;            </div>
<div class="line"><a name="l00716"></a><span class="lineno">  716</span>&#160;    <span class="comment">// if one node&#39;s partition wasn&#39;t equal, all-nodes must report not-equal</span></div>
<div class="line"><a name="l00717"></a><span class="lineno">  717</span>&#160;    <span class="keywordtype">int</span> allAmpsAgree = ampsAgree;</div>
<div class="line"><a name="l00718"></a><span class="lineno">  718</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00719"></a><span class="lineno">  719</span>&#160;    MPI_Allreduce(&amp;ampsAgree, &amp;allAmpsAgree, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00720"></a><span class="lineno">  720</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00721"></a><span class="lineno">  721</span>&#160; </div>
<div class="line"><a name="l00722"></a><span class="lineno">  722</span>&#160;    <span class="keywordflow">return</span> allAmpsAgree;</div>
<div class="line"><a name="l00723"></a><span class="lineno">  723</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00039">copyStateFromGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

</div>
</div>
<a id="ga45cc399adad2e2a67b0124851189fae5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga45cc399adad2e2a67b0124851189fae5">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[8/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns true if the absolute value of the difference between every amplitude in vectors <code>a</code> and <code>b</code> is less than <code>REAL_EPS</code>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00387">387</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;                                    {</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( a.size() == b.size() );</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    </div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;a.size(); i++)</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;        <span class="keywordflow">if</span> (abs(a[i] - b[i]) &gt; REAL_EPS)</div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00724">areEqual()</a>, <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, <a class="el" href="utilities_8cpp_source.html#l00485">getRandomUnitary()</a>, and <a class="el" href="test__data__structures_8cpp_source.html#l00057">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga7753296a935e1dc1b6dfb98607cd2afa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7753296a935e1dc1b6dfb98607cd2afa">&#9670;&nbsp;</a></span>areEqual() <span class="overload">[9/9]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool areEqual </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>reals</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>imags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns true if the absolute value of the difference between every element in <code>vec</code> and those implied by <code>reals</code> and <code>imags</code>, is less than <code>REAL_EPS</code>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00823">823</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;                                                       {</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;    </div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dif;</div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;vec.size(); i++) {</div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160;        dif = abs(real(vec[i]) - reals[i]);</div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160;        <span class="keywordflow">if</span> (dif &gt; REAL_EPS)</div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00830"></a><span class="lineno">  830</span>&#160;        dif = abs(imag(vec[i]) - imags[i]);</div>
<div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160;        <span class="keywordflow">if</span> (dif &gt; REAL_EPS)</div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00833"></a><span class="lineno">  833</span>&#160;    }</div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00835"></a><span class="lineno">  835</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="ga2e09685323c6b2312a64daf8c74b12b5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2e09685323c6b2312a64daf8c74b12b5">&#9670;&nbsp;</a></span>bitsets()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; bitsets </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numBits</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every <code>numBits-length</code> bit-set, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention). </p>
<p>Note that the produced bitset must not be modified during generation.</p>
<p>This function can be used like </p><pre class="fragment">int* bits = GENERATE( bitsets(3) );
</pre><p>to produce {0,0,0}, {1,0,0}, {0,1,0}, {1,1,0}, {0,0,1}, {1,0,1}, {0,1,1}, {1,1,1}.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01268">1268</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>&#160;                                                           {    </div>
<div class="line"><a name="l01269"></a><span class="lineno"> 1269</span>&#160;    <span class="keywordflow">return</span> Catch::Generators::GeneratorWrapper&lt;int*&gt;(</div>
<div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>&#160;        std::unique_ptr&lt;Catch::Generators::IGenerator&lt;int*&gt;&gt;(</div>
<div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>&#160;            <span class="keyword">new</span> <a class="code" href="classSequenceGenerator.html">SequenceGenerator&lt;int&gt;</a>(1, numBits)));</div>
<div class="line"><a name="l01272"></a><span class="lineno"> 1272</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="test__unitaries_8cpp_source.html#l01607">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga267884197cf7f1d428021cb12a57360c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga267884197cf7f1d428021cb12a57360c">&#9670;&nbsp;</a></span>calcLog2()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned int calcLog2 </td>
          <td>(</td>
          <td class="paramtype">long unsigned int&#160;</td>
          <td class="paramname"><em>num</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns log2 of numbers which must be gauranteed to be 2^n. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones</dd></dl>
<p>Returns log2 of numbers which must be gauranteed to be 2^n. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__validation_8c_source.html#l00292">292</a> of file <a class="el" href="QuEST__validation_8c_source.html">QuEST_validation.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;                                             {</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> l = 0;</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;    <span class="keywordflow">while</span> (num &gt;&gt;= 1)</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;        l++;</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    <span class="keywordflow">return</span> l;</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00692">applyReferenceMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>, <a class="el" href="test__data__structures_8cpp_source.html#l00131">TEST_CASE()</a>, <a class="el" href="QuEST__validation_8c_source.html#l00329">validateNumQubitsInDiagOp()</a>, and <a class="el" href="QuEST__validation_8c_source.html#l00313">validateNumQubitsInQureg()</a>.</p>

</div>
</div>
<a id="ga3cf199a7de3bbcb3546503f25be9245a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3cf199a7de3bbcb3546503f25be9245a">&#9670;&nbsp;</a></span>getConjugateTranspose()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getConjugateTranspose </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>a</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the conjugate transpose of the complex square matrix <code>a</code>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00179">179</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;                                         {</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> b = a;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r=0; r&lt;a.size(); r++)</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c=0; c&lt;a.size(); c++)</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;            b[r][c] = conj(a[c][r]);</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    <span class="keywordflow">return</span> b;</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00629">applyReferenceOp()</a>, <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, and <a class="el" href="utilities_8cpp_source.html#l00485">getRandomUnitary()</a>.</p>

</div>
</div>
<a id="gac60cee26113732c491f21dc43066b605"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac60cee26113732c491f21dc43066b605">&#9670;&nbsp;</a></span>getExponentialOfDiagonalMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getExponentialOfDiagonalMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>a</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the matrix exponential of a diagonal, square, complex matrix. </p>
<p>This method explicitly checks that the passed matrix <code>a</code> is diagonal.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00187">187</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;                                                  {</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    </div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="comment">// ensure diagonal</span></div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r=0; r&lt;a.size(); r++)</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c=0; c&lt;a.size(); c++) {</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;            <span class="keywordflow">if</span> (r == c)</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;                <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( a[r][c] == 0. );</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;        }</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160; </div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    <span class="comment">// exp(diagonal) = diagonal(exp)</span></div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> diag = a;</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;a.size(); i++)</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;        diag[i][i] = exp(diag[i][i]);</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        </div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    <span class="keywordflow">return</span> diag;</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__unitaries_8cpp_source.html#l01533">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga00f4feec845c019c3390898b0cc7f1ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga00f4feec845c019c3390898b0cc7f1ef">&#9670;&nbsp;</a></span>getExponentialOfPauliMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getExponentialOfPauliMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>angle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>a</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the matrix exponential of a kronecker product of pauli matrices (or of any involutory matrices), with exponent factor (-i <code>angle</code> / 2). </p>
<p>This method will not explicitly check that the passed matrix <code>a</code> is kronecker product of involutory matrices, but will otherwise return an incorrect exponential.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00205">205</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;                                                            {</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> iden = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(a.size());</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> expo = (cos(angle/2) * iden) + (-1i * sin(angle/2) * a);</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    <span class="keywordflow">return</span> expo;</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__unitaries_8cpp_source.html#l01429">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga20f041452b43026d876fde17a5999265"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga20f041452b43026d876fde17a5999265">&#9670;&nbsp;</a></span>getFullOperatorMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getFullOperatorMatrix </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>ctrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numCtrls</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>op</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Takes a 2^<code>numTargs-by-2^<code>numTargs</code> matrix</code> <code>op</code> and a returns a 2^<code>numQubits-by-2^<code>numQubits</code> matrix</code> where <code>op</code> is controlled on the given <code>ctrls</code> qubits. </p>
<p>The union of {<code>ctrls}</code> and {<code>targs}</code> must be unique (though this is not explicitly checked), and every element must be &gt;= 0 (not checked). The passed {<code>ctrls}</code> and {<code>targs}</code> arrays are unmodified.</p>
<p>This funciton works by first swapping {<code>targs}</code> and {<code>ctrls}</code> (via swap unitaries) to be strictly increasing {0,1,...}, building controlled(<code>op</code>), tensoring it to the full Hilbert space, and then 'unswapping'. The returned matrix has form: swap1 ... swapN . controlled(<code>op</code>) . swapN ... swap1</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00293">293</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;  {        </div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numCtrls &gt;= 0 );</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numTargs &gt;= 0 );</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numQubits &gt;= (numCtrls+numTargs) );</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( op.size() == (1u &lt;&lt; numTargs) );</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;    </div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;    <span class="comment">// copy {ctrls} and {targs}to restore at end</span></div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;    std::vector&lt;int&gt; ctrlsCopy(ctrls, ctrls+numCtrls);</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;    std::vector&lt;int&gt; targsCopy(targs, targs+numTargs);</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;    </div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;    <span class="comment">// full-state matrix of qubit swaps</span></div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> swaps = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQubits);</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> unswaps = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQubits);</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr;</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;    </div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;    <span class="comment">// swap targs to {0, ..., numTargs-1}</span></div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numTargs; i++) {</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;        <span class="keywordflow">if</span> (i != targs[i]) {</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;            matr = <a class="code" href="group__testutilities.html#ga37e0f375a6c50721aaf68153f750e842">getSwapMatrix</a>(i, targs[i], numQubits);</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;            swaps = matr * swaps;</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;            unswaps = unswaps * matr;</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;            </div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;            <span class="comment">// even if this is the last targ, ctrls might still need updating</span></div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;            <a class="code" href="utilities_8cpp.html#a5a70927d32d5ddd0f704767919d8ed01">updateIndices</a>(</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;                i, targs[i], (i &lt; numTargs-1)? &amp;targs[i+1] : NULL, </div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;                numTargs-i-1, ctrls, numCtrls);</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;        }</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;    }</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160; </div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;    <span class="comment">// swap ctrls to {numTargs, ..., numTargs+numCtrls-1}</span></div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numCtrls; i++) {</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;        <span class="keywordtype">int</span> newInd = numTargs+i;</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;        <span class="keywordflow">if</span> (newInd != ctrls[i]) {</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;            matr = <a class="code" href="group__testutilities.html#ga37e0f375a6c50721aaf68153f750e842">getSwapMatrix</a>(newInd, ctrls[i], numQubits);</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;            swaps = matr * swaps;</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;            unswaps = unswaps * matr;</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;            </div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;            <span class="comment">// update remaining ctrls (if any exist)</span></div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;            <span class="keywordflow">if</span> (i &lt; numCtrls-1)</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;                <a class="code" href="utilities_8cpp.html#a5a70927d32d5ddd0f704767919d8ed01">updateIndices</a>(newInd, ctrls[i], NULL, 0, &amp;ctrls[i+1], numCtrls-i-1);</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;        }</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;    }</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;    </div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;    <span class="comment">// construct controlled-op matrix for qubits {0, ..., numCtrls+numTargs-1}</span></div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;    <span class="keywordtype">size_t</span> dim = 1 &lt;&lt; (numCtrls+numTargs);</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> fullOp = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(dim);</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;    <a class="code" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a>(fullOp, op, dim-op.size(), dim-op.size());</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;    </div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;    <span class="comment">// create full-state controlled-op matrix (left-pad identities)</span></div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;    <span class="keywordflow">if</span> (numQubits &gt; numCtrls+numTargs) {</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;        <span class="keywordtype">size_t</span> pad = 1 &lt;&lt; (numQubits - numCtrls - numTargs);</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;        fullOp = <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(<a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(pad), fullOp);</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;    }</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;    </div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;    <span class="comment">// apply swap to either side (to swap qubits back and forth)</span></div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;    fullOp = unswaps * fullOp * swaps;</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    </div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;    <span class="comment">// restore {ctrls and targs}</span></div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numCtrls; i++)</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;        ctrls[i] = ctrlsCopy[i];</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numTargs; i++)</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;        targs[i] = targsCopy[i];</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160; </div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;    <span class="keywordflow">return</span> fullOp;</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00169">getKroneckerProduct()</a>, <a class="el" href="utilities_8cpp_source.html#l00219">getSwapMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00211">setSubMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00276">updateIndices()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00692">applyReferenceMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00573">applyReferenceOp()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gac0c6339c28256f2aae86d443fae44455"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac0c6339c28256f2aae86d443fae44455">&#9670;&nbsp;</a></span>getIdentityMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getIdentityMatrix </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>dim</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a dim-by-dim identity matrix. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00151">151</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;                                      {</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( dim &gt; 1 );</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(dim);</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;dim; i++)</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;        matr[i][i] = 1;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00205">getExponentialOfPauliMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, <a class="el" href="utilities_8cpp_source.html#l00485">getRandomUnitary()</a>, and <a class="el" href="utilities_8cpp_source.html#l00219">getSwapMatrix()</a>.</p>

</div>
</div>
<a id="ga2de7d3b138728b6beb7753b82df61803"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2de7d3b138728b6beb7753b82df61803">&#9670;&nbsp;</a></span>getKetBra()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getKetBra </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>ket</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>bra</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the matrix |<code>ket&gt;&lt;<code>bra|</code>,</code> with ith-jth element <code>ket(i)</code> conj(<code>bra(j)</code>), since |<code>ket&gt;&lt;<code>bra|</code> =</code> sum_i a_i|i&gt; sum_j b_j* &lt;j| = sum_{ij} a_i b_j* |i&gt;&lt;j|. </p>
<p>The dimensions of bra and ket must agree, and the returned square complex matrix has dimensions size(bra) x size(bra).</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00159">159</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;                                            {</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( ket.size() == bra.size() );</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> mat = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(ket.size());</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    </div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r=0; r&lt;ket.size(); r++)</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c=0; c&lt;ket.size(); c++)</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;            mat[r][c] = ket[r] * conj(bra[c]);</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;    <span class="keywordflow">return</span> mat;</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00457">getRandomDensityMatrix()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga50616e813b0d0aa4f8220785d780cdff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga50616e813b0d0aa4f8220785d780cdff">&#9670;&nbsp;</a></span>getKroneckerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getKroneckerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the kronecker product of <code>a</code> and <code>b</code>, where <code>a</code> and <code>b</code> are square but possibly differently-sized complex matrices. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00169">169</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;                                                  {</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> prod = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(a.size() * b.size());</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r=0; r&lt;b.size(); r++)</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c=0; c&lt;b.size(); c++)</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;a.size(); i++)</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;                <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;a.size(); j++)</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;                    prod[r+b.size()*i][c+b.size()*j] = a[i][j] * b[r][c];</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    <span class="keywordflow">return</span> prod;</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00219">getSwapMatrix()</a>, <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l01066">toQMatrix()</a>.</p>

</div>
</div>
<a id="ga5438455c2c8ecf5948ca22875313a590"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5438455c2c8ecf5948ca22875313a590">&#9670;&nbsp;</a></span>getNormalised()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> getNormalised </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>vec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns an L2-normalised copy of <code>vec</code>, using Kahan summation for improved accuracy. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00431">431</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;                                   {</div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> norm = 0;</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> y, t, c;</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;    c = 0;</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    </div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;vec.size(); i++) {</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;        y = real(vec[i])*real(vec[i]) - c;</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;        t = norm + y;</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;        c = ( t - norm ) - y;</div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;        norm = t;</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;        </div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;        y = imag(vec[i])*imag(vec[i]) - c;</div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;        t = norm + y;</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;        c = ( t - norm ) - y;</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;        norm = t;</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;    }</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    </div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;vec.size(); i++)</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;        vec[i] /= sqrt(norm);</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;    <span class="keywordflow">return</span> vec;</div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00453">getRandomStateVector()</a>.</p>

</div>
</div>
<a id="ga617b0fd1eb1c395762c937ad3b23e61b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga617b0fd1eb1c395762c937ad3b23e61b">&#9670;&nbsp;</a></span>getRandomDensityMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getRandomDensityMatrix </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a random <code>numQb-by-<code>numQb</code> density</code> matrix, from an undisclosed distribution, in a very mixed state. </p>
<p>This function works by generating 2^<code>numQb</code> random pure states, and mixing them with random probabilities.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00457">457</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;                                          {</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numQb &gt; 0 );</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;    </div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;    <span class="comment">// generate random probabilities to weight random pure states</span></div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;    <span class="keywordtype">int</span> dim = 1&lt;&lt;numQb;</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probs[dim];</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> probNorm = 0;</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;dim; i++) {</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;        probs[i] = <a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(0, 1);</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;        probNorm += probs[i];</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;    }</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;dim; i++)</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;        probs[i] /= probNorm;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;    </div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;    <span class="comment">// add random pure states</span></div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> dens = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(dim);</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;dim; i++) {</div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;        <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> pure = <a class="code" href="group__testutilities.html#gae1d2eb70b50267f8186cbd53e300d94f">getRandomStateVector</a>(numQb);</div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;        dens += probs[i] * <a class="code" href="group__testutilities.html#ga2de7d3b138728b6beb7753b82df61803">getKetBra</a>(pure, pure);</div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;    }</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;    </div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;    <span class="keywordflow">return</span> dens;</div>
<div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00159">getKetBra()</a>, <a class="el" href="utilities_8cpp_source.html#l00410">getRandomReal()</a>, <a class="el" href="utilities_8cpp_source.html#l00453">getRandomStateVector()</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga7125d0747a44db58115899727ac5f6be"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7125d0747a44db58115899727ac5f6be">&#9670;&nbsp;</a></span>getRandomInt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int getRandomInt </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>max</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a random integer between <code>min</code> (inclusive) and <code>max</code> (exclusive), from the uniform distribution. </p>
<p>Demands that <code>max</code> &gt; <code>min</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00481">481</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;                                   {</div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;    <span class="keywordflow">return</span> round(<a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(min, max-1));</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00410">getRandomReal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l01054">setRandomPauliSum()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga0d3b30625e2350a1e837a0b259dd3b18"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0d3b30625e2350a1e837a0b259dd3b18">&#9670;&nbsp;</a></span>getRandomKrausMap()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt;<a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&gt; getRandomKrausMap </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numOps</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a random Kraus map of <code>#numOps</code> 2^<code>numQb-by-2^<code>numQb</code> operators</code>, from an undisclosed distribution. </p>
<p>Note this method is very simple and cannot generate all possible Kraus maps. It works by generating <code>numOps</code> random unitary matrices, and randomly re-normalising them, such that the sum of ops[j]^dagger ops[j] = 1</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00533">533</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00533"></a><span class="lineno">  533</span>&#160;                                                            {</div>
<div class="line"><a name="l00534"></a><span class="lineno">  534</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numOps &gt;= 1 );</div>
<div class="line"><a name="l00535"></a><span class="lineno">  535</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numOps &lt;= 4*numQb*numQb );</div>
<div class="line"><a name="l00536"></a><span class="lineno">  536</span>&#160; </div>
<div class="line"><a name="l00537"></a><span class="lineno">  537</span>&#160;    <span class="comment">// generate random unitaries</span></div>
<div class="line"><a name="l00538"></a><span class="lineno">  538</span>&#160;    std::vector&lt;QMatrix&gt; ops;</div>
<div class="line"><a name="l00539"></a><span class="lineno">  539</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00540"></a><span class="lineno">  540</span>&#160;        ops.push_back(<a class="code" href="group__testutilities.html#ga1a5e9b668716b91dd8527ce00f7500cf">getRandomUnitary</a>(numQb));</div>
<div class="line"><a name="l00541"></a><span class="lineno">  541</span>&#160;        </div>
<div class="line"><a name="l00542"></a><span class="lineno">  542</span>&#160;    <span class="comment">// generate random weights</span></div>
<div class="line"><a name="l00543"></a><span class="lineno">  543</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> weights[numOps];</div>
<div class="line"><a name="l00544"></a><span class="lineno">  544</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00545"></a><span class="lineno">  545</span>&#160;        weights[i] = <a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(0, 1);</div>
<div class="line"><a name="l00546"></a><span class="lineno">  546</span>&#160;        </div>
<div class="line"><a name="l00547"></a><span class="lineno">  547</span>&#160;    <span class="comment">// normalise random weights</span></div>
<div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> weightSum = 0;</div>
<div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;        weightSum += weights[i];</div>
<div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00552"></a><span class="lineno">  552</span>&#160;        weights[i] = sqrt(weights[i]/weightSum);</div>
<div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160;        </div>
<div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;    <span class="comment">// normalise ops</span></div>
<div class="line"><a name="l00555"></a><span class="lineno">  555</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160;        ops[i] *= weights[i];</div>
<div class="line"><a name="l00557"></a><span class="lineno">  557</span>&#160;        </div>
<div class="line"><a name="l00558"></a><span class="lineno">  558</span>&#160;    <span class="comment">// check what we produced was a valid Kraus map</span></div>
<div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> iden = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> prodSum = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00561"></a><span class="lineno">  561</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numOps; i++)</div>
<div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160;        prodSum += <a class="code" href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">getConjugateTranspose</a>(ops[i]) * ops[i];</div>
<div class="line"><a name="l00563"></a><span class="lineno">  563</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( <a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(prodSum, iden) );</div>
<div class="line"><a name="l00564"></a><span class="lineno">  564</span>&#160;        </div>
<div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;    <span class="keywordflow">return</span> ops;</div>
<div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00387">areEqual()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00179">getConjugateTranspose()</a>, <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00410">getRandomReal()</a>, <a class="el" href="utilities_8cpp_source.html#l00485">getRandomUnitary()</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00229">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gaa2e8b958e0cba07e01de9f91a5ce3c9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa2e8b958e0cba07e01de9f91a5ce3c9c">&#9670;&nbsp;</a></span>getRandomQMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getRandomQMatrix </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>dim</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a <code>dim-by-<code>dim</code> complex</code> matrix, where the real and imaginary value of each element are independently random, under the standard normal distribution (mean 0, standard deviation 1). </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00368">368</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;                                  {</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( dim &gt; 1 );</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;    </div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(dim);</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;dim; i++) {</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0; j&lt;dim; j++) {</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;            </div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;            <span class="comment">// generate 2 normally-distributed random numbers via Box-Muller</span></div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;            <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> a = rand()/(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) RAND_MAX;</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;            <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> b = rand()/(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) RAND_MAX;</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;            <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> r1 = sqrt(-2 * log(a)) * cos(2 * 3.14159265 * b);</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;            <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> r2 = sqrt(-2 * log(a)) * sin(2 * 3.14159265 * b);</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;            </div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;            matr[i][j] = r1 + r2*1i;</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;        }</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;    }</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00485">getRandomUnitary()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga27dc818709394cb31247e26850215f8a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga27dc818709394cb31247e26850215f8a">&#9670;&nbsp;</a></span>getRandomQVector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> getRandomQVector </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>dim</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a <code>dim-length</code> vector with random complex amplitudes in the square joining {-1-i, 1+i}, of an undisclosed distribution. </p>
<p>The resulting vector is NOT L2-normalised.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00420">420</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;                                  { </div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;    <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec = <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>(dim);</div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;dim; i++)</div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;        vec[i] = <a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(-1,1) + 1i*<a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(-1,1);</div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;        </div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    <span class="comment">// check we didn&#39;t get the impossibly-unlikely zero-amplitude outcome </span></div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( real(vec[0]) != 0 );</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;        </div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;    <span class="keywordflow">return</span> vec;</div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="utilities_8cpp_source.html#l00410">getRandomReal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00453">getRandomStateVector()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00554">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gacd5aadbe10ecdedaa625f85171c0a3cd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacd5aadbe10ecdedaa625f85171c0a3cd">&#9670;&nbsp;</a></span>getRandomReal()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> getRandomReal </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>min</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>max</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a random real between <code>min</code> (inclusive) and <code>max</code> (exclusive), from the uniform distribution. </p>
<p>Demands that <code>max</code> &gt; <code>min</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00410">410</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;                                          {</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( min &lt;= max );</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> r = min + (max - min) * (rand() / (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>) RAND_MAX);</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;    </div>
<div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;    <span class="comment">// check bounds satisfied </span></div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( r &gt;= min );</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( r &lt;= max );</div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    <span class="keywordflow">return</span> r;</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00457">getRandomDensityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00481">getRandomInt()</a>, <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, <a class="el" href="utilities_8cpp_source.html#l00420">getRandomQVector()</a>, <a class="el" href="utilities_8cpp_source.html#l01054">setRandomPauliSum()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00111">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gae1d2eb70b50267f8186cbd53e300d94f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae1d2eb70b50267f8186cbd53e300d94f">&#9670;&nbsp;</a></span>getRandomStateVector()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> getRandomStateVector </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a random <code>numQb-length</code> L2-normalised state-vector from an undisclosed distribution. </p>
<p>This function works by randomly generating each complex amplitude, then L2-normalising.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00453">453</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;                                        {</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#ga5438455c2c8ecf5948ca22875313a590">getNormalised</a>(<a class="code" href="group__testutilities.html#ga27dc818709394cb31247e26850215f8a">getRandomQVector</a>(1&lt;&lt;numQb));</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00431">getNormalised()</a>, and <a class="el" href="utilities_8cpp_source.html#l00420">getRandomQVector()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00457">getRandomDensityMatrix()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga1a5e9b668716b91dd8527ce00f7500cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1a5e9b668716b91dd8527ce00f7500cf">&#9670;&nbsp;</a></span>getRandomUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getRandomUnitary </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQb</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a uniformly random (under Haar) 2^<code>numQb-by-2^<code>numQb</code> unitary</code> matrix. </p>
<p>This function works by first generating a complex matrix where each element is independently random; the real and imaginary component thereof are independent standard normally-distributed (mean 0, standard-dev 1). Then, the matrix is orthonormalised via the Gram Schmidt algorithm. The resulting unitary matrix MAY be uniformly distributed under the Haar measure, but we make no assurance. This routine may return an identity matrix if it was unable to sufficiently precisely produce a unitary of the given size.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00485">485</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;                                    {</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numQb &gt;= 1 );</div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160; </div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr = <a class="code" href="group__testutilities.html#gaa2e8b958e0cba07e01de9f91a5ce3c9c">getRandomQMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160; </div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;matr.size(); i++) {</div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;        <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> row = matr[i];</div>
<div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;        </div>
<div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;        <span class="comment">// compute new orthogonal row by subtracting proj row onto prevs</span></div>
<div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k=i-1; k&gt;=0; k--) {</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160; </div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;            <span class="comment">// compute row . prev = sum_n row_n conj(prev_n)</span></div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;            <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a> prod = 0;</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> n=0; n&lt;row.size(); n++)</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;                prod += row[n] * conj(matr[k][n]);</div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;                            </div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;            <span class="comment">// subtract (proj row onto prev) = (prod * prev) from final row</span></div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> n=0; n&lt;row.size(); n++)</div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;                matr[i][n] -= prod * matr[k][n];</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;        }</div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;    </div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;        <span class="comment">// compute row magnitude </span></div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> mag = 0;</div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;row.size(); j++)</div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;            mag += pow(abs(matr[i][j]), 2);</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;        mag = sqrt(mag);</div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;        </div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;        <span class="comment">// normalise row</span></div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;row.size(); j++)</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;            matr[i][j] /= mag;</div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;    }</div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;    </div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;    <span class="comment">// ensure matrix is indeed unitary </span></div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> conjprod = matr * <a class="code" href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">getConjugateTranspose</a>(matr);</div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> iden = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;    </div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;    <span class="comment">// generating big unitary matrices is hard; if we fail, default to identity</span></div>
<div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;    <span class="keywordflow">if</span> ( numQb &gt;= 3 &amp;&amp; !<a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(conjprod, iden) ) {</div>
<div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;        </div>
<div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;        matr = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;        conjprod = matr;</div>
<div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;    }</div>
<div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( <a class="code" href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a>(conjprod, iden) );</div>
<div class="line"><a name="l00528"></a><span class="lineno">  528</span>&#160;    </div>
<div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;    <span class="comment">// return the new orthonormal matrix</span></div>
<div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00387">areEqual()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00179">getConjugateTranspose()</a>, <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00368">getRandomQMatrix()</a>, <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, and <a class="el" href="test__unitaries_8cpp_source.html#l00155">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga37e0f375a6c50721aaf68153f750e842"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga37e0f375a6c50721aaf68153f750e842">&#9670;&nbsp;</a></span>getSwapMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getSwapMatrix </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the 2^<code>numQb-by-2^<code>numQb</code> unitary</code> matrix which swaps qubits <code>qb1</code> and <code>qb2</code>; the SWAP gate of not-necessarily-adjacent qubits. </p>
<p>If <code>qb1</code> == <code>qb2</code>, returns the identity matrix.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00219">219</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;                                                   {</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( numQb &gt; 1 );</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( (qb1 &gt;= 0 &amp;&amp; qb1 &lt; numQb) );</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( (qb2 &gt;= 0 &amp;&amp; qb2 &lt; numQb) );</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    </div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    <span class="keywordflow">if</span> (qb1 &gt; qb2)</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;        std::swap(qb1, qb2);</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        </div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    <span class="keywordflow">if</span> (qb1 == qb2)</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1 &lt;&lt; numQb);</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160; </div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> swap;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    </div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;    <span class="keywordflow">if</span> (qb2 == qb1 + 1) {</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;        <span class="comment">// qubits are adjacent</span></div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;        swap = <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>{{1,0,0,0},{0,0,1,0},{0,1,0,0},{0,0,0,1}};</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;        </div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;        <span class="comment">// qubits are distant</span></div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        <span class="keywordtype">int</span> block = 1 &lt;&lt; (qb2 - qb1);</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        swap = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(block*2);</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> iden = <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(block/2);</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;        </div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;        <span class="comment">// Lemma 3.1 of arxiv.org/pdf/1711.09765.pdf</span></div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> p0{{1,0},{0,0}};</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> l0{{0,1},{0,0}};</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> l1{{0,0},{1,0}};</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> p1{{0,0},{0,1}};</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;        </div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;        <span class="comment">/* notating a^(n+1) = identity(1&lt;&lt;n) (otimes) a, we construct the matrix</span></div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;<span class="comment">         * [ p0^(N) l1^N ]</span></div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;<span class="comment">         * [ l0^(N) p1^N ]</span></div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;<span class="comment">         * where N = qb2 - qb1 */</span></div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;        <a class="code" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a>(swap, <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(iden, p0), 0, 0);</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;        <a class="code" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a>(swap, <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(iden, l0), block, 0);</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;        <a class="code" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a>(swap, <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(iden, l1), 0, block);</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;        <a class="code" href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a>(swap, <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(iden, p1), block, block);</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    }</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;    </div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="comment">// pad swap with outer identities</span></div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    <span class="keywordflow">if</span> (qb1 &gt; 0)</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;        swap = <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(swap, <a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1&lt;&lt;qb1));</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    <span class="keywordflow">if</span> (qb2 &lt; numQb-1)</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;        swap = <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(<a class="code" href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a>(1&lt;&lt;(numQb-qb2-1)), swap);</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;        </div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;    <span class="keywordflow">return</span> swap;</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00169">getKroneckerProduct()</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00211">setSubMatrix()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>.</p>

</div>
</div>
<a id="ga6ccbb15b0f234e926be96a153181b63a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6ccbb15b0f234e926be96a153181b63a">&#9670;&nbsp;</a></span>getZeroMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> getZeroMatrix </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>dim</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a dim-by-dim square complex matrix, initialised to all zeroes. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00143">143</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;                                  {</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( dim &gt; 1 );</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr = <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>(dim);</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;dim; i++)</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        matr[i].resize(dim);</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00151">getIdentityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00159">getKetBra()</a>, <a class="el" href="utilities_8cpp_source.html#l00169">getKroneckerProduct()</a>, <a class="el" href="utilities_8cpp_source.html#l00457">getRandomDensityMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00533">getRandomKrausMap()</a>, <a class="el" href="utilities_8cpp_source.html#l00368">getRandomQMatrix()</a>, <a class="el" href="utilities_8cpp_source.html#l00219">getSwapMatrix()</a>, <a class="el" href="test__data__structures_8cpp_source.html#l00103">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l00869">toQMatrix()</a>.</p>

</div>
</div>
<a id="gac102c131efa312dabd5462e6e2642975"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac102c131efa312dabd5462e6e2642975">&#9670;&nbsp;</a></span>pauliseqs()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;<a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a>*&gt; pauliseqs </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numPaulis</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every <code>numPaulis-length</code> set of Pauli-matrix types (or base-4 integers). </p>
<p>Generates in increasing lexographic order, where the left-most (zero index) pauli is treated as LEAST significant. Note that the sequence must not be modified during generation.</p>
<p>This function can be used like </p><pre class="fragment">pauliOpType* set = GENERATE( pauliseqs(2) );
</pre><p>to produce {I,I}, {X,I}, {Y,I}, {Z,I}, {I,X}, {X,X}, {Y,X}, {Z,X}, {I,Y}, {X,Y}, {Y,Y}, {Z,Y}, {I,Z}, {X,Z}, {Y,Z}, {Z,Z}/</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01278">1278</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01278"></a><span class="lineno"> 1278</span>&#160;                                                                       {    </div>
<div class="line"><a name="l01279"></a><span class="lineno"> 1279</span>&#160;    <span class="keywordflow">return</span> Catch::Generators::GeneratorWrapper&lt;pauliOpType*&gt;(</div>
<div class="line"><a name="l01280"></a><span class="lineno"> 1280</span>&#160;        std::unique_ptr&lt;Catch::Generators::IGenerator&lt;pauliOpType*&gt;&gt;(</div>
<div class="line"><a name="l01281"></a><span class="lineno"> 1281</span>&#160;            <span class="keyword">new</span> <a class="code" href="classSequenceGenerator.html">SequenceGenerator&lt;pauliOpType&gt;</a>(<a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a>, numPaulis)));</div>
<div class="line"><a name="l01282"></a><span class="lineno"> 1282</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00096">PAULI_Z</a>.</p>

</div>
</div>
<a id="ga181366c4cdc7786bcc066e8ac8342c1d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga181366c4cdc7786bcc066e8ac8342c1d">&#9670;&nbsp;</a></span>sequences()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; sequences </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>base</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numDigits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every <code>numDigits-length</code> sequence in the given <code>base</code>, in increasing lexographic order, where left-most (zero index) bit is treated as LEAST significant (opposite typical convention). </p>
<p>Note that the sequence must not be modified during generation.</p>
<p>This function can be used like </p><pre class="fragment">int base = 3;
int numDigits = 2;
int* seq = GENERATE_COPY( sequences(base, numDigits) );
</pre><p>to produce {0,0}, {1,0}, {2,0}, {0,1}, {1,1}, {2,1}, {0,2}, {1,2}, {2,2}.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01273">1273</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>&#160;                                                                         {    </div>
<div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>&#160;    <span class="keywordflow">return</span> Catch::Generators::GeneratorWrapper&lt;int*&gt;(</div>
<div class="line"><a name="l01275"></a><span class="lineno"> 1275</span>&#160;        std::unique_ptr&lt;Catch::Generators::IGenerator&lt;int*&gt;&gt;(</div>
<div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>&#160;            <span class="keyword">new</span> <a class="code" href="classSequenceGenerator.html">SequenceGenerator&lt;int&gt;</a>(base-1, numDigits)));</div>
<div class="line"><a name="l01277"></a><span class="lineno"> 1277</span>&#160;}</div>
</div><!-- fragment -->
</div>
</div>
<a id="gafaecff2462bd0b490edff484911d831e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafaecff2462bd0b490edff484911d831e">&#9670;&nbsp;</a></span>setRandomPauliSum() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void setRandomPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Populates <code>hamil</code> with random coefficients and pauli codes. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01062">1062</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;                                         {</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;    <a class="code" href="group__testutilities.html#ga11c465ce1a5c238946a9e09d61c94c58">setRandomPauliSum</a>(hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>, hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>, hamil.<a class="code" href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">numQubits</a>, hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>);</div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00168">PauliHamil::numQubits</a>, <a class="el" href="QuEST_8h_source.html#l00166">PauliHamil::numSumTerms</a>, <a class="el" href="QuEST_8h_source.html#l00162">PauliHamil::pauliCodes</a>, <a class="el" href="utilities_8cpp_source.html#l01054">setRandomPauliSum()</a>, and <a class="el" href="QuEST_8h_source.html#l00164">PauliHamil::termCoeffs</a>.</p>

</div>
</div>
<a id="ga11c465ce1a5c238946a9e09d61c94c58"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga11c465ce1a5c238946a9e09d61c94c58">&#9670;&nbsp;</a></span>setRandomPauliSum() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void setRandomPauliSum </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>codes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTerms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Populates the <code>coeffs</code> array with random qreals in (-5, 5), and populates <code>codes</code> with random Pauli codes. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01054">1054</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;                                                                                       {</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;    <span class="keywordtype">int</span> i=0;</div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n=0; n&lt;numTerms; n++) {</div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;        coeffs[n] = <a class="code" href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a>(-5, 5);</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q=0; q&lt;numQubits; q++)</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;            codes[i++] = (<a class="code" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a>) <a class="code" href="group__testutilities.html#ga7125d0747a44db58115899727ac5f6be">getRandomInt</a>(0,4);</div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>&#160;    }</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00481">getRandomInt()</a>, and <a class="el" href="utilities_8cpp_source.html#l00410">getRandomReal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l01062">setRandomPauliSum()</a>, and <a class="el" href="test__calculations_8cpp_source.html#l00183">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga75966a02c618790c1de5f0102ab8398f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga75966a02c618790c1de5f0102ab8398f">&#9670;&nbsp;</a></span>setSubMatrix()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void setSubMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> &amp;&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>sub</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>r</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>c</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Modifies <code>dest</code> by overwriting its submatrix (from top-left corner (<code>r</code>, <code>c</code>) to bottom-right corner (<code>r</code> + <code>dest.size()</code>, <code>c</code> + <code>dest.size()</code>) with the complete elements of sub. </p>
<p>This demands that dest.size() &gt;= sub.size() + max(r,c).</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00211">211</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;                                                                  {</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( sub.size() + r &lt;= dest.size() );</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( sub.size() + c &lt;= dest.size() );</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;sub.size(); i++)</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j&lt;sub.size(); j++)</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;            dest[r+i][c+j] = sub[i][j];</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>.</p>

<p class="reference">Referenced by <a class="el" href="utilities_8cpp_source.html#l00293">getFullOperatorMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00219">getSwapMatrix()</a>.</p>

</div>
</div>
<a id="gab724b72e679a9be95ff5e01b076928df"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab724b72e679a9be95ff5e01b076928df">&#9670;&nbsp;</a></span>sublists() <span class="overload">[1/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; sublists </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;&#160;</td>
          <td class="paramname"><em>gen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSamps</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int *&#160;</td>
          <td class="paramname"><em>exclude</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numExclude</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code>, which exclude all elements in <code>exclude</code>, in increasing lexographic order. </p>
<p>This generates every fixed-length combination of <code>gen's</code> elements the nominated exclusions, and every permutation of each.</p>
<p>There is on need for the elements of <code>exclude</code> to actually appear in those of <code>gen</code>. <code>sublen</code> must less than or equal to the number of elements in <code>gen</code>, after the nominated exclusions.</p>
<p>Note that the sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes <code>list</code> contains no duplicates, otherwise the generated sublists may be duplicated.</p>
<p>This function can be used like </p><pre class="fragment">int sublen = 2;
int exclude[2] = {3,4};
int* sublist = GENERATE_COPY( sublists(range(1,6), sublen, exclude, 2) );
</pre><p>to generate {1,2}, {1,5}, {2,1}, {2,5}, {5,1}, {5,2}</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

</div>
</div>
<a id="gae479aa71f65fce301d64ed8cd9118e95"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae479aa71f65fce301d64ed8cd9118e95">&#9670;&nbsp;</a></span>sublists() <span class="overload">[2/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; sublists </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;&#160;</td>
          <td class="paramname"><em>gen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numSamps</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>excluded</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code> which exclude element <code>excluded</code>, in increasing lexographic order. </p>
<p>This generates every fixed-length combination of <code>gen's</code> elements the nominated exclusions, and every permutation of each.</p>
<p><code>sublen</code> must less than or equal to the number of elements in <code>gen</code>, after the nominated exclusion. There is no need for <code>excluded</code> to actually appear in the elements of <code>gen</code>.</p>
<p>Note that the sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes <code>list</code> contains no duplicates, otherwise the generated sublists may be duplicated.</p>
<p>This function can be used like </p><pre class="fragment">int sublen = 2;
int excluded = 1;
int* sublist = GENERATE_COPY( sublists(range(1,4), sublen, excluded) );
</pre><p>to generate {2,3}, {3,2}.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

</div>
</div>
<a id="gabe5be8b856a9f67e392db86a62d8cf31"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabe5be8b856a9f67e392db86a62d8cf31">&#9670;&nbsp;</a></span>sublists() <span class="overload">[3/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; sublists </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt; int &gt; &amp;&amp;&#160;</td>
          <td class="paramname"><em>gen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>sublen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every length-<code>sublen</code> sublist of the elements generated by <code>gen</code>, in increasing lexographic order. </p>
<p>This generates every fixed-length combination of <code>gen's</code> elements, and every permutation of each. Note that the produced sublist must not be modified, else further generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes <code>list</code> contains no duplicates, otherwise the generated sublists may be duplicated.</p>
<p>This function can be used like </p><pre class="fragment">int sublen = 2;
int* sublist = GENERATE_COPY( sublists(list, 4, sublen) );
</pre><p>to generate {1,2}, {1,3}, {1,4}, {2,1}, {2,3}, {2,4}, {3,1}, {3,2}, {3, 4}, {4,1}, {4,2}, {4, 3}.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

</div>
</div>
<a id="ga35add15146aa606b256df79334b867d5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga35add15146aa606b256df79334b867d5">&#9670;&nbsp;</a></span>sublists() <span class="overload">[4/4]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="utilities_8hpp.html#a8cc85fff30c23faa2cbed6ca0c01ce39">CatchGen</a>&lt;int*&gt; sublists </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>list</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>sublen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a Catch2 generator of every length-<code>sublen</code> sublist of length-<code>len</code> <code>list</code>, in increasing lexographic order. </p>
<p>This generates every fixed-length combination of the given list and every permutation of each. &amp; If the sublist length is the full list length, this generator produces every permutation correctly. Note that the sublist must not be modified, else further &amp; generation may break (QuEST's internal functions will indeed modify but restore the qubit index lists given to them, which is ok). Assumes <code>list</code> contains no duplicates, otherwise the generated sublists may be duplicated.</p>
<p>This function can be used like </p><pre class="fragment">int list[4] = {1,2,3,4};
int sublen = 2;
int* sublist = GENERATE_COPY( sublists(list, 4, sublen) );
</pre><p>to generate {1,2}, {1,3}, {1,4}, {2,1}, {2,3}, {2,4}, {3,1}, {3,2}, {3, 4}, {4,1}, {4,2}, {4, 3}.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01199">1199</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>&#160;  {    </div>
<div class="line"><a name="l01202"></a><span class="lineno"> 1202</span>&#160;    <span class="keywordflow">return</span> Catch::Generators::GeneratorWrapper&lt;int*&gt;(</div>
<div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>&#160;        std::unique_ptr&lt;Catch::Generators::IGenerator&lt;int*&gt;&gt;(</div>
<div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>&#160;            <span class="keyword">new</span> <a class="code" href="classSubListGenerator.html">SubListGenerator</a>(list, len, sublen)));</div>
<div class="line"><a name="l01205"></a><span class="lineno"> 1205</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00296">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga731a7a71755c25ebe96e742e3fbe5812"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga731a7a71755c25ebe96e742e3fbe5812">&#9670;&nbsp;</a></span>toComplexMatrix2()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> toComplexMatrix2 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>qm</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a <code><a class="el" href="structComplexMatrix2.html" title="Represents a 2x2 matrix of complex numbers.">ComplexMatrix2</a></code> copy of QMatix <code>qm</code>. </p>
<p>Demands that <code>qm</code> is a 2-by-2 matrix.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00846">846</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00846"></a><span class="lineno">  846</span>&#160;                                            {</div>
<div class="line"><a name="l00847"></a><span class="lineno">  847</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qm.size() == 2 );</div>
<div class="line"><a name="l00848"></a><span class="lineno">  848</span>&#160;    <a class="code" href="structComplexMatrix2.html">ComplexMatrix2</a> cm;</div>
<div class="line"><a name="l00849"></a><span class="lineno">  849</span>&#160;    <a class="code" href="utilities_8cpp.html#a3ab1cbd3fcacfb4f40e6898da03f8705">macro_copyQMatrix</a>(cm, qm);</div>
<div class="line"><a name="l00850"></a><span class="lineno">  850</span>&#160;    <span class="keywordflow">return</span> cm;</div>
<div class="line"><a name="l00851"></a><span class="lineno">  851</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="utilities_8cpp_source.html#l00838">macro_copyQMatrix</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00520">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga216f7c25bbb0cf752d1b6fff5ea8197b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga216f7c25bbb0cf752d1b6fff5ea8197b">&#9670;&nbsp;</a></span>toComplexMatrix4()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> toComplexMatrix4 </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>qm</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a <code><a class="el" href="structComplexMatrix4.html" title="Represents a 4x4 matrix of complex numbers.">ComplexMatrix4</a></code> copy of QMatix <code>qm</code>. </p>
<p>Demands that <code>qm</code> is a 4-by-4 matrix.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00852">852</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00852"></a><span class="lineno">  852</span>&#160;                                            {</div>
<div class="line"><a name="l00853"></a><span class="lineno">  853</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qm.size() == 4 );</div>
<div class="line"><a name="l00854"></a><span class="lineno">  854</span>&#160;    <a class="code" href="structComplexMatrix4.html">ComplexMatrix4</a> cm;</div>
<div class="line"><a name="l00855"></a><span class="lineno">  855</span>&#160;    <a class="code" href="utilities_8cpp.html#a3ab1cbd3fcacfb4f40e6898da03f8705">macro_copyQMatrix</a>(cm, qm);</div>
<div class="line"><a name="l00856"></a><span class="lineno">  856</span>&#160;    <span class="keywordflow">return</span> cm;</div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, and <a class="el" href="utilities_8cpp_source.html#l00838">macro_copyQMatrix</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00720">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga7f83695bea7d0332a577bca017dbb03c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7f83695bea7d0332a577bca017dbb03c">&#9670;&nbsp;</a></span>toComplexMatrixN()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void toComplexMatrixN </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>qm</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>cm</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialises <code>cm</code> with the values of <code>qm</code>. </p>
<p>Demands that <code>cm</code> is a previously created <a class="el" href="structComplexMatrixN.html" title="Represents a general 2^N by 2^N matrix of complex numbers.">ComplexMatrixN</a> instance, with the same dimensions as <code>qm</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00858">858</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;                                                     {</div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qm.size() == (1u&lt;&lt;cm.<a class="code" href="structComplexMatrixN.html#a606f7afbc3f65a596bdca21cb43be6a8">numQubits</a>) );</div>
<div class="line"><a name="l00860"></a><span class="lineno">  860</span>&#160;    <a class="code" href="utilities_8cpp.html#a3ab1cbd3fcacfb4f40e6898da03f8705">macro_copyQMatrix</a>(cm, qm);</div>
<div class="line"><a name="l00861"></a><span class="lineno">  861</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00838">macro_copyQMatrix</a>, and <a class="el" href="QuEST_8h_source.html#l00138">ComplexMatrixN::numQubits</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__decoherence_8cpp_source.html#l00229">TEST_CASE()</a>.</p>

</div>
</div>
<a id="gad552153e13f45cf6c7d6447ae6d9551a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad552153e13f45cf6c7d6447ae6d9551a">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[1/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the matrix (where a=<code>alpha</code>, b=<code>beta</code>) {{a, -conj(b)}, {b, conj(a)}} using the <code>qcomp</code> complex type. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00887">887</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00887"></a><span class="lineno">  887</span>&#160;                                               {</div>
<div class="line"><a name="l00888"></a><span class="lineno">  888</span>&#160;    <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a> a = <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>(alpha.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>, alpha.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>);</div>
<div class="line"><a name="l00889"></a><span class="lineno">  889</span>&#160;    <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a> b = <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>(beta.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>, beta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>);</div>
<div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr{</div>
<div class="line"><a name="l00891"></a><span class="lineno">  891</span>&#160;        {a, -conj(b)},</div>
<div class="line"><a name="l00892"></a><span class="lineno">  892</span>&#160;        {b,  conj(a)}};</div>
<div class="line"><a name="l00893"></a><span class="lineno">  893</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00894"></a><span class="lineno">  894</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>, and <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>.</p>

</div>
</div>
<a id="ga253946523907014c4f198d2bb38d4913"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga253946523907014c4f198d2bb38d4913">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[2/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>src</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a copy of the given 2-by-2 matrix. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00869">869</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00869"></a><span class="lineno">  869</span>&#160;                                      {</div>
<div class="line"><a name="l00870"></a><span class="lineno">  870</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> dest = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(2);</div>
<div class="line"><a name="l00871"></a><span class="lineno">  871</span>&#160;    <a class="code" href="utilities_8cpp.html#a21e0fa8d57dc566ad149077be8f67a82">macro_copyComplexMatrix</a>(dest, src);</div>
<div class="line"><a name="l00872"></a><span class="lineno">  872</span>&#160;    <span class="keywordflow">return</span> dest;</div>
<div class="line"><a name="l00873"></a><span class="lineno">  873</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00864">macro_copyComplexMatrix</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00111">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l01095">toQMatrix()</a>.</p>

</div>
</div>
<a id="ga3dbd53326151e3c6c5e0de579f6554a7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3dbd53326151e3c6c5e0de579f6554a7">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[3/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>src</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a copy of the given 4-by-4 matrix. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00874">874</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00874"></a><span class="lineno">  874</span>&#160;                                      {</div>
<div class="line"><a name="l00875"></a><span class="lineno">  875</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> dest = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(4);</div>
<div class="line"><a name="l00876"></a><span class="lineno">  876</span>&#160;    <a class="code" href="utilities_8cpp.html#a21e0fa8d57dc566ad149077be8f67a82">macro_copyComplexMatrix</a>(dest, src);</div>
<div class="line"><a name="l00877"></a><span class="lineno">  877</span>&#160;    <span class="keywordflow">return</span> dest;</div>
<div class="line"><a name="l00878"></a><span class="lineno">  878</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, and <a class="el" href="utilities_8cpp_source.html#l00864">macro_copyComplexMatrix</a>.</p>

</div>
</div>
<a id="gadbcd76cb251c802e7f81803bdd23064b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadbcd76cb251c802e7f81803bdd23064b">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[4/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>src</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a copy of the given 2^<code>N-by-2^<code>N</code> matrix</code>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00879">879</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00879"></a><span class="lineno">  879</span>&#160;                                      {</div>
<div class="line"><a name="l00880"></a><span class="lineno">  880</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( src.<a class="code" href="structComplexMatrixN.html#a446e8a077597e4f76049d547df0c9738">real</a> != NULL );</div>
<div class="line"><a name="l00881"></a><span class="lineno">  881</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( src.<a class="code" href="structComplexMatrixN.html#afde13e469a3b4f179f45e53d1ec0a7cf">imag</a> != NULL );</div>
<div class="line"><a name="l00882"></a><span class="lineno">  882</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> dest = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(1 &lt;&lt; src.<a class="code" href="structComplexMatrixN.html#a606f7afbc3f65a596bdca21cb43be6a8">numQubits</a>);</div>
<div class="line"><a name="l00883"></a><span class="lineno">  883</span>&#160;    <a class="code" href="utilities_8cpp.html#a21e0fa8d57dc566ad149077be8f67a82">macro_copyComplexMatrix</a>(dest, src);</div>
<div class="line"><a name="l00884"></a><span class="lineno">  884</span>&#160;    <span class="keywordflow">return</span> dest;</div>
<div class="line"><a name="l00885"></a><span class="lineno">  885</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, <a class="el" href="QuEST_8h_source.html#l00140">ComplexMatrixN::imag</a>, <a class="el" href="utilities_8cpp_source.html#l00864">macro_copyComplexMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00138">ComplexMatrixN::numQubits</a>, and <a class="el" href="QuEST_8h_source.html#l00139">ComplexMatrixN::real</a>.</p>

</div>
</div>
<a id="ga95a4a8d36ad12018f5ffe92f39f4cfb8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga95a4a8d36ad12018f5ffe92f39f4cfb8">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[5/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a 2^<code>N-by-2^<code>N</code> complex</code> diagonal matrix form of the <a class="el" href="structDiagonalOp.html" title="Represents a diagonal complex operator on the full Hilbert state of a Qureg.">DiagonalOp</a>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01018">1018</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>&#160;                                 {</div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>&#160;    <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec = <a class="code" href="group__testutilities.html#gade0e7c37811a69f1c21c88c11943a19f">toQVector</a>(op);</div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> mat = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(1LL &lt;&lt; op.<a class="code" href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">numQubits</a>);</div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i&lt;mat.size(); i++)</div>
<div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>&#160;        mat[i][i] = vec[i];</div>
<div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>&#160;    <span class="keywordflow">return</span> mat;</div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, and <a class="el" href="utilities_8cpp_source.html#l00938">toQVector()</a>.</p>

</div>
</div>
<a id="gae1131c2c5e1a36b5b6e2b614c6d7cdc8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae1131c2c5e1a36b5b6e2b614c6d7cdc8">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[6/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structPauliHamil.html">PauliHamil</a>&#160;</td>
          <td class="paramname"><em>hamil</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a 2^<code>N-by-2^<code>N</code> Hermitian</code> matrix form of the <a class="el" href="structPauliHamil.html" title="Represents a weighted sum of pauli products.">PauliHamil</a>. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01095">1095</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>&#160;                                    {</div>
<div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__testutilities.html#ga253946523907014c4f198d2bb38d4913">toQMatrix</a>(hamil.<a class="code" href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">termCoeffs</a>, hamil.<a class="code" href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">pauliCodes</a>, hamil.<a class="code" href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">numQubits</a>, hamil.<a class="code" href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">numSumTerms</a>);</div>
<div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00168">PauliHamil::numQubits</a>, <a class="el" href="QuEST_8h_source.html#l00166">PauliHamil::numSumTerms</a>, <a class="el" href="QuEST_8h_source.html#l00162">PauliHamil::pauliCodes</a>, <a class="el" href="QuEST_8h_source.html#l00164">PauliHamil::termCoeffs</a>, and <a class="el" href="utilities_8cpp_source.html#l00869">toQMatrix()</a>.</p>

</div>
</div>
<a id="ga29dd7da2b0f2104a90c88fb081e67a0e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga29dd7da2b0f2104a90c88fb081e67a0e">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[7/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> *&#160;</td>
          <td class="paramname"><em>coeffs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> *&#160;</td>
          <td class="paramname"><em>paulis</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTerms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a 2^<code>N-by-2^<code>N</code> Hermitian</code> matrix form of the specified weighted sum of Pauli products. </p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01066">1066</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;                                                                                   {</div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160;    </div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;    <span class="comment">// produce a numTargs-big matrix &#39;pauliSum&#39; by pauli-matrix tensoring and summing</span></div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> iMatr{{1,0},{0,1}};</div>
<div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> xMatr{{0,1},{1,0}};</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> yMatr{{0,-1i},{1i,0}};</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> zMatr{{1,0},{0,-1}};</div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> pauliSum = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(1&lt;&lt;<a class="code" href="utilities_8hpp.html#a2f52338126bb8cdf7fcf68eaf01c546a">NUM_QUBITS</a>);</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;    </div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTerms; t++) {</div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;        <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> pauliProd = <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>{{1}};</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;        </div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q=0; q&lt;numQubits; q++) {</div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;            <span class="keywordtype">int</span> i = q + t*numQubits;</div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>&#160;            </div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;            <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> fac;</div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>&#160;            <a class="code" href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a> code = paulis[i];</div>
<div class="line"><a name="l01083"></a><span class="lineno"> 1083</span>&#160;            <span class="keywordflow">if</span> (code == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a>) fac = iMatr;</div>
<div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>&#160;            <span class="keywordflow">if</span> (code == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a>) fac = xMatr;</div>
<div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>&#160;            <span class="keywordflow">if</span> (code == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a>) fac = yMatr;</div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>&#160;            <span class="keywordflow">if</span> (code == <a class="code" href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a>) fac = zMatr;</div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>&#160;            pauliProd = <a class="code" href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a>(fac, pauliProd);</div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>&#160;        }</div>
<div class="line"><a name="l01089"></a><span class="lineno"> 1089</span>&#160;        pauliSum += coeffs[t] * pauliProd;</div>
<div class="line"><a name="l01090"></a><span class="lineno"> 1090</span>&#160;    }</div>
<div class="line"><a name="l01091"></a><span class="lineno"> 1091</span>&#160;    </div>
<div class="line"><a name="l01092"></a><span class="lineno"> 1092</span>&#160;    <span class="comment">// a now 2^numQubits by 2^numQubits Hermitian matrix</span></div>
<div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>&#160;    <span class="keywordflow">return</span> pauliSum;</div>
<div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00169">getKroneckerProduct()</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, <a class="el" href="utilities_8hpp_source.html#l00036">NUM_QUBITS</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_I</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_X</a>, <a class="el" href="QuEST_8h_source.html#l00096">PAULI_Y</a>, and <a class="el" href="QuEST_8h_source.html#l00096">PAULI_Z</a>.</p>

</div>
</div>
<a id="ga4c4ce1767ee2ef420c0078ea5991aeb0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4c4ce1767ee2ef420c0078ea5991aeb0">&#9670;&nbsp;</a></span>toQMatrix() <span class="overload">[8/8]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> toQMatrix </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns an equal-size copy of the given density matrix <code>qureg</code>. </p>
<p>In GPU mode, this function involves a copy of <code>qureg</code> from GPU memory to RAM. In distributed mode, this involves an all-to-all broadcast of <code>qureg</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00896">896</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;                               {</div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l00898"></a><span class="lineno">  898</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> &lt; MPI_MAX_AMPS_IN_MSG );</div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00901"></a><span class="lineno">  901</span>&#160;    </div>
<div class="line"><a name="l00902"></a><span class="lineno">  902</span>&#160;    <span class="comment">// ensure local qureg.stateVec is up to date</span></div>
<div class="line"><a name="l00903"></a><span class="lineno">  903</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;    </div>
<div class="line"><a name="l00906"></a><span class="lineno">  906</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullRe;</div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullIm;</div>
<div class="line"><a name="l00908"></a><span class="lineno">  908</span>&#160;    </div>
<div class="line"><a name="l00909"></a><span class="lineno">  909</span>&#160;    <span class="comment">// in distributed mode, give every node the full state vector</span></div>
<div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;    fullRe = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> * <span class="keyword">sizeof</span> *fullRe);</div>
<div class="line"><a name="l00912"></a><span class="lineno">  912</span>&#160;    fullIm = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> * <span class="keyword">sizeof</span> *fullIm);</div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00914"></a><span class="lineno">  914</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;        fullRe, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00917"></a><span class="lineno">  917</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00918"></a><span class="lineno">  918</span>&#160;        fullIm, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00919"></a><span class="lineno">  919</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00920"></a><span class="lineno">  920</span>&#160;    fullRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00921"></a><span class="lineno">  921</span>&#160;    fullIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00922"></a><span class="lineno">  922</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00923"></a><span class="lineno">  923</span>&#160;        </div>
<div class="line"><a name="l00924"></a><span class="lineno">  924</span>&#160;    <span class="comment">// copy full state vector into a QVector</span></div>
<div class="line"><a name="l00925"></a><span class="lineno">  925</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> dim = (1 &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00926"></a><span class="lineno">  926</span>&#160;    <a class="code" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a> matr = <a class="code" href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a>(dim);</div>
<div class="line"><a name="l00927"></a><span class="lineno">  927</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> n=0; n&lt;qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>; n++)</div>
<div class="line"><a name="l00928"></a><span class="lineno">  928</span>&#160;        matr[n%dim][n/dim] = <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>(fullRe[n], fullIm[n]);</div>
<div class="line"><a name="l00929"></a><span class="lineno">  929</span>&#160;    </div>
<div class="line"><a name="l00930"></a><span class="lineno">  930</span>&#160;    <span class="comment">// clean up if we malloc&#39;d the distributed array</span></div>
<div class="line"><a name="l00931"></a><span class="lineno">  931</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00932"></a><span class="lineno">  932</span>&#160;    free(fullRe);</div>
<div class="line"><a name="l00933"></a><span class="lineno">  933</span>&#160;    free(fullIm);</div>
<div class="line"><a name="l00934"></a><span class="lineno">  934</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00935"></a><span class="lineno">  935</span>&#160;    <span class="keywordflow">return</span> matr;</div>
<div class="line"><a name="l00936"></a><span class="lineno">  936</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00039">copyStateFromGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="utilities_8cpp_source.html#l00143">getZeroMatrix()</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

</div>
</div>
<a id="ga5e1bcff9f5867273c4d413a60dc78e8e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5e1bcff9f5867273c4d413a60dc78e8e">&#9670;&nbsp;</a></span>toQureg() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void toQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a>&#160;</td>
          <td class="paramname"><em>mat</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialises the density matrix <code>qureg</code> to have the same amplitudes as <code>mat</code>. </p>
<p>Demands <code>qureg</code> is a density matrix of equal dimensions to <code>mat</code>. In GPU mode, this function involves a copy from RAM to GPU memory. This function has no communication cost in distributed mode.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01039">1039</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>&#160;                                       {</div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( (1 &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>) == (<span class="keywordtype">int</span>) mat.size() );</div>
<div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>&#160;    </div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>&#160;    </div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>&#160;    <span class="keywordtype">int</span> len = (1 &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; i++) {</div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>&#160;        <span class="keywordtype">int</span> ind = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> + i;</div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] = real(mat[ind%len][ind/len]);</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] = imag(mat[ind%len][ind/len]);</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;    }</div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;    <a class="code" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a>(qureg);</div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00036">copyStateToGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

</div>
</div>
<a id="gaf5a18d4c00dfe0523972be3bfc666362"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf5a18d4c00dfe0523972be3bfc666362">&#9670;&nbsp;</a></span>toQureg() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void toQureg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>&#160;</td>
          <td class="paramname"><em>vec</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialises the state-vector <code>qureg</code> to have the same amplitudes as <code>vec</code>. </p>
<p>Demands <code>qureg</code> is a state-vector of an equal size to <code>vec</code>. In GPU mode, this function involves a copy from RAM to GPU memory. This function has no communication cost in distributed mode.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l01026">1026</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>&#160;                                       {</div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( !qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> == (<span class="keywordtype">int</span>) vec.size() );</div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span>&#160;    </div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l01031"></a><span class="lineno"> 1031</span>&#160;    </div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; i++) {</div>
<div class="line"><a name="l01033"></a><span class="lineno"> 1033</span>&#160;        <span class="keywordtype">int</span> ind = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> + i;</div>
<div class="line"><a name="l01034"></a><span class="lineno"> 1034</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[i] = real(vec[ind]);</div>
<div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[i] = imag(vec[ind]);</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>&#160;    }</div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>&#160;    <a class="code" href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a>(qureg);</div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00036">copyStateToGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00015">TEST_CASE()</a>.</p>

</div>
</div>
<a id="ga09f18ab46d2b17ad13185c0b4c06b400"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga09f18ab46d2b17ad13185c0b4c06b400">&#9670;&nbsp;</a></span>toQVector() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> toQVector </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns a vector with the same of the full diagonal operator, populated with <code>op's</code> elements. </p>
<p>In distributed mode, this involves an all-to-all broadcast of <code>op</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00980">980</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00980"></a><span class="lineno">  980</span>&#160;                                 {</div>
<div class="line"><a name="l00981"></a><span class="lineno">  981</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> totalElems = (1LL &lt;&lt; op.<a class="code" href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">numQubits</a>);</div>
<div class="line"><a name="l00982"></a><span class="lineno">  982</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00983"></a><span class="lineno">  983</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( totalElems &lt; MPI_MAX_AMPS_IN_MSG );</div>
<div class="line"><a name="l00984"></a><span class="lineno">  984</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00985"></a><span class="lineno">  985</span>&#160;    </div>
<div class="line"><a name="l00986"></a><span class="lineno">  986</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullRe;</div>
<div class="line"><a name="l00987"></a><span class="lineno">  987</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullIm;</div>
<div class="line"><a name="l00988"></a><span class="lineno">  988</span>&#160;    </div>
<div class="line"><a name="l00989"></a><span class="lineno">  989</span>&#160;    <span class="comment">// in distributed mode, give every node the full diagonal operator</span></div>
<div class="line"><a name="l00990"></a><span class="lineno">  990</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00991"></a><span class="lineno">  991</span>&#160;    fullRe = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(totalElems * <span class="keyword">sizeof</span> *fullRe);</div>
<div class="line"><a name="l00992"></a><span class="lineno">  992</span>&#160;    fullIm = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(totalElems * <span class="keyword">sizeof</span> *fullIm);</div>
<div class="line"><a name="l00993"></a><span class="lineno">  993</span>&#160;            </div>
<div class="line"><a name="l00994"></a><span class="lineno">  994</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00995"></a><span class="lineno">  995</span>&#160;        op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00996"></a><span class="lineno">  996</span>&#160;        fullRe, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00997"></a><span class="lineno">  997</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00998"></a><span class="lineno">  998</span>&#160;        op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00999"></a><span class="lineno">  999</span>&#160;        fullIm, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01000"></a><span class="lineno"> 1000</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>&#160;    fullRe = op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>;</div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span>&#160;    fullIm = op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>;</div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>&#160;    </div>
<div class="line"><a name="l01005"></a><span class="lineno"> 1005</span>&#160;    <span class="comment">// copy full state vector into a QVector</span></div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>&#160;    <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec = <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>(totalElems);</div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> i=0; i&lt;totalElems; i++)</div>
<div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>&#160;        vec[i] = <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>(fullRe[i], fullIm[i]);</div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>&#160;            </div>
<div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>&#160;    <span class="comment">// clean up if we malloc&#39;d distrib array</span></div>
<div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>&#160;    free(fullRe);</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>&#160;    free(fullIm);</div>
<div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>&#160;    <span class="keywordflow">return</span> vec;</div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00183">DiagonalOp::numElemsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00181">DiagonalOp::numQubits</a>, <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

</div>
</div>
<a id="gade0e7c37811a69f1c21c88c11943a19f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gade0e7c37811a69f1c21c88c11943a19f">&#9670;&nbsp;</a></span>toQVector() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> toQVector </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns an equal-size copy of the given state-vector <code>qureg</code>. </p>
<p>In GPU mode, this function involves a copy of <code>qureg</code> from GPU memory to RAM. In distributed mode, this involves an all-to-all broadcast of <code>qureg</code>.</p>
<dl class="section author"><dt>Author</dt><dd>Tyson Jones </dd></dl>

<p class="definition">Definition at line <a class="el" href="utilities_8cpp_source.html#l00938">938</a> of file <a class="el" href="utilities_8cpp_source.html">utilities.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00938"></a><span class="lineno">  938</span>&#160;                               {</div>
<div class="line"><a name="l00939"></a><span class="lineno">  939</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( !qureg.<a class="code" href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">isDensityMatrix</a> );</div>
<div class="line"><a name="l00940"></a><span class="lineno">  940</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00941"></a><span class="lineno">  941</span>&#160;    <a class="code" href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a>( qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> &lt; MPI_MAX_AMPS_IN_MSG );</div>
<div class="line"><a name="l00942"></a><span class="lineno">  942</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00943"></a><span class="lineno">  943</span>&#160;    </div>
<div class="line"><a name="l00944"></a><span class="lineno">  944</span>&#160;    <span class="comment">// ensure local qureg.stateVec is up to date</span></div>
<div class="line"><a name="l00945"></a><span class="lineno">  945</span>&#160;    <a class="code" href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a>(qureg);</div>
<div class="line"><a name="l00946"></a><span class="lineno">  946</span>&#160;    <a class="code" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a>(<a class="code" href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a>);</div>
<div class="line"><a name="l00947"></a><span class="lineno">  947</span>&#160;    </div>
<div class="line"><a name="l00948"></a><span class="lineno">  948</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullRe;</div>
<div class="line"><a name="l00949"></a><span class="lineno">  949</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* fullIm;</div>
<div class="line"><a name="l00950"></a><span class="lineno">  950</span>&#160;    </div>
<div class="line"><a name="l00951"></a><span class="lineno">  951</span>&#160;    <span class="comment">// in distributed mode, give every node the full state vector</span></div>
<div class="line"><a name="l00952"></a><span class="lineno">  952</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00953"></a><span class="lineno">  953</span>&#160;    fullRe = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> * <span class="keyword">sizeof</span> *fullRe);</div>
<div class="line"><a name="l00954"></a><span class="lineno">  954</span>&#160;    fullIm = (<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>*) malloc(qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a> * <span class="keyword">sizeof</span> *fullIm);</div>
<div class="line"><a name="l00955"></a><span class="lineno">  955</span>&#160;            </div>
<div class="line"><a name="l00956"></a><span class="lineno">  956</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00957"></a><span class="lineno">  957</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00958"></a><span class="lineno">  958</span>&#160;        fullRe, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00959"></a><span class="lineno">  959</span>&#160;    MPI_Allgather(</div>
<div class="line"><a name="l00960"></a><span class="lineno">  960</span>&#160;        qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00961"></a><span class="lineno">  961</span>&#160;        fullIm, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, MPI_QuEST_REAL, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00962"></a><span class="lineno">  962</span>&#160;<span class="preprocessor">#else</span></div>
<div class="line"><a name="l00963"></a><span class="lineno">  963</span>&#160;    fullRe = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00964"></a><span class="lineno">  964</span>&#160;    fullIm = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00965"></a><span class="lineno">  965</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00966"></a><span class="lineno">  966</span>&#160;    </div>
<div class="line"><a name="l00967"></a><span class="lineno">  967</span>&#160;    <span class="comment">// copy full state vector into a QVector</span></div>
<div class="line"><a name="l00968"></a><span class="lineno">  968</span>&#160;    <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a> vec = <a class="code" href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a>(qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>);</div>
<div class="line"><a name="l00969"></a><span class="lineno">  969</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> i=0; i&lt;qureg.<a class="code" href="structQureg.html#adef4935cac95763c29164cf99b144ed4">numAmpsTotal</a>; i++)</div>
<div class="line"><a name="l00970"></a><span class="lineno">  970</span>&#160;        vec[i] = <a class="code" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>(fullRe[i], fullIm[i]);</div>
<div class="line"><a name="l00971"></a><span class="lineno">  971</span>&#160;            </div>
<div class="line"><a name="l00972"></a><span class="lineno">  972</span>&#160;    <span class="comment">// clean up if we malloc&#39;d distrib array</span></div>
<div class="line"><a name="l00973"></a><span class="lineno">  973</span>&#160;<span class="preprocessor">#ifdef DISTRIBUTED_MODE</span></div>
<div class="line"><a name="l00974"></a><span class="lineno">  974</span>&#160;    free(fullRe);</div>
<div class="line"><a name="l00975"></a><span class="lineno">  975</span>&#160;    free(fullIm);</div>
<div class="line"><a name="l00976"></a><span class="lineno">  976</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00977"></a><span class="lineno">  977</span>&#160;    <span class="keywordflow">return</span> vec;</div>
<div class="line"><a name="l00978"></a><span class="lineno">  978</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00039">copyStateFromGPU()</a>, <a class="el" href="utilities_8cpp_source.html#l00024">DEMAND</a>, <a class="el" href="QuEST_8h_source.html#l00206">Qureg::isDensityMatrix</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00215">Qureg::numAmpsTotal</a>, <a class="el" href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="main_8cpp_source.html#l00020">QUEST_ENV</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00162">syncQuESTEnv()</a>.</p>

<p class="reference">Referenced by <a class="el" href="test__calculations_8cpp_source.html#l00111">TEST_CASE()</a>, and <a class="el" href="utilities_8cpp_source.html#l01018">toQMatrix()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="agroup__type_html_ga1c703cf89629e4e9c7023cd402d67028"><div class="ttname"><a href="group__type.html#ga1c703cf89629e4e9c7023cd402d67028">pauliOpType</a></div><div class="ttdeci">pauliOpType</div><div class="ttdoc">Codes for specifying Pauli operators.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga20f041452b43026d876fde17a5999265"><div class="ttname"><a href="group__testutilities.html#ga20f041452b43026d876fde17a5999265">getFullOperatorMatrix</a></div><div class="ttdeci">QMatrix getFullOperatorMatrix(int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op, int numQubits)</div><div class="ttdoc">Takes a 2^numTargs-by-2^numTargs matrix op and a returns a 2^numQubits-by-2^numQubits matrix where op...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00293">utilities.cpp:293</a></div></div>
<div class="ttc" id="agroup__debug_html_ga924ef2dbda6b733b4041270077c76ece"><div class="ttname"><a href="group__debug.html#ga924ef2dbda6b733b4041270077c76ece">copyStateFromGPU</a></div><div class="ttdeci">void copyStateFromGPU(Qureg qureg)</div><div class="ttdoc">In GPU mode, this copies the state-vector (or density matrix) from GPU memory (qureg....</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00039">QuEST_cpu.c:39</a></div></div>
<div class="ttc" id="amain_8cpp_html_a718130cc1fc36cde991aff3d4c85c47d"><div class="ttname"><a href="main_8cpp.html#a718130cc1fc36cde991aff3d4c85c47d">QUEST_ENV</a></div><div class="ttdeci">QuESTEnv QUEST_ENV</div><div class="ttdoc">The global QuESTEnv instance, to be created and destroyed once in this main(), so that the MPI enviro...</div><div class="ttdef"><b>Definition:</b> <a href="main_8cpp_source.html#l00020">main.cpp:20</a></div></div>
<div class="ttc" id="agroup__debug_html_ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><div class="ttname"><a href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a></div><div class="ttdeci">void syncQuESTEnv(QuESTEnv env)</div><div class="ttdoc">Guarantees that all code up to the given point has been executed on all nodes (if running in distribu...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00162">QuEST_cpu_distributed.c:162</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a085c85cff6ba79c52d8b1e61c42ddddf">PAULI_Z</a></div><div class="ttdeci">@ PAULI_Z</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="aclassSubListGenerator_html"><div class="ttname"><a href="classSubListGenerator.html">SubListGenerator</a></div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l01099">utilities.cpp:1099</a></div></div>
<div class="ttc" id="autilities_8cpp_html_a21e0fa8d57dc566ad149077be8f67a82"><div class="ttname"><a href="utilities_8cpp.html#a21e0fa8d57dc566ad149077be8f67a82">macro_copyComplexMatrix</a></div><div class="ttdeci">#define macro_copyComplexMatrix(dest, src)</div><div class="ttdoc">Copies ComplexMatrix structures into a QMatrix.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00864">utilities.cpp:864</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a63800f45b01ccc2608f754aee850bf4a">PAULI_I</a></div><div class="ttdeci">@ PAULI_I</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga3cf199a7de3bbcb3546503f25be9245a"><div class="ttname"><a href="group__testutilities.html#ga3cf199a7de3bbcb3546503f25be9245a">getConjugateTranspose</a></div><div class="ttdeci">QMatrix getConjugateTranspose(QMatrix a)</div><div class="ttdoc">Returns the conjugate transpose of the complex square matrix a.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00179">utilities.cpp:179</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga7125d0747a44db58115899727ac5f6be"><div class="ttname"><a href="group__testutilities.html#ga7125d0747a44db58115899727ac5f6be">getRandomInt</a></div><div class="ttdeci">int getRandomInt(int min, int max)</div><div class="ttdoc">Returns a random integer between min (inclusive) and max (exclusive), from the uniform distribution.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00481">utilities.cpp:481</a></div></div>
<div class="ttc" id="autilities_8hpp_html_a2f52338126bb8cdf7fcf68eaf01c546a"><div class="ttname"><a href="utilities_8hpp.html#a2f52338126bb8cdf7fcf68eaf01c546a">NUM_QUBITS</a></div><div class="ttdeci">#define NUM_QUBITS</div><div class="ttdoc">The default number of qubits in the registers created for unit testing (both statevectors and density...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8hpp_source.html#l00036">utilities.hpp:36</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga37e0f375a6c50721aaf68153f750e842"><div class="ttname"><a href="group__testutilities.html#ga37e0f375a6c50721aaf68153f750e842">getSwapMatrix</a></div><div class="ttdeci">QMatrix getSwapMatrix(int qb1, int qb2, int numQb)</div><div class="ttdoc">Returns the 2^numQb-by-2^numQb unitary matrix which swaps qubits qb1 and qb2; the SWAP gate of not-ne...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00219">utilities.cpp:219</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga1a5e9b668716b91dd8527ce00f7500cf"><div class="ttname"><a href="group__testutilities.html#ga1a5e9b668716b91dd8527ce00f7500cf">getRandomUnitary</a></div><div class="ttdeci">QMatrix getRandomUnitary(int numQb)</div><div class="ttdoc">Returns a uniformly random (under Haar) 2^numQb-by-2^numQb unitary matrix.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00485">utilities.cpp:485</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gacd5aadbe10ecdedaa625f85171c0a3cd"><div class="ttname"><a href="group__testutilities.html#gacd5aadbe10ecdedaa625f85171c0a3cd">getRandomReal</a></div><div class="ttdeci">qreal getRandomReal(qreal min, qreal max)</div><div class="ttdoc">Returns a random real between min (inclusive) and max (exclusive), from the uniform distribution.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00410">utilities.cpp:410</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga2de7d3b138728b6beb7753b82df61803"><div class="ttname"><a href="group__testutilities.html#ga2de7d3b138728b6beb7753b82df61803">getKetBra</a></div><div class="ttdeci">QMatrix getKetBra(QVector ket, QVector bra)</div><div class="ttdoc">Returns the matrix |ket&gt;&lt;bra|, with ith-jth element ket(i) conj(bra(j)), since |ket&gt;&lt;bra| = sum_i a_i...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00159">utilities.cpp:159</a></div></div>
<div class="ttc" id="astructComplexMatrix4_html"><div class="ttname"><a href="structComplexMatrix4.html">ComplexMatrix4</a></div><div class="ttdoc">Represents a 4x4 matrix of complex numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00125">QuEST.h:125</a></div></div>
<div class="ttc" id="agroup__type_html_ga7740e349b4f8bae6451547680f0ce2d6"><div class="ttname"><a href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a></div><div class="ttdeci">#define qreal</div></div>
<div class="ttc" id="agroup__testutilities_html_ga253946523907014c4f198d2bb38d4913"><div class="ttname"><a href="group__testutilities.html#ga253946523907014c4f198d2bb38d4913">toQMatrix</a></div><div class="ttdeci">QMatrix toQMatrix(ComplexMatrix2 src)</div><div class="ttdoc">Returns a copy of the given 2-by-2 matrix.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00869">utilities.cpp:869</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga267884197cf7f1d428021cb12a57360c"><div class="ttname"><a href="group__testutilities.html#ga267884197cf7f1d428021cb12a57360c">calcLog2</a></div><div class="ttdeci">unsigned int calcLog2(long unsigned int res)</div><div class="ttdoc">Returns log2 of numbers which must be gauranteed to be 2^n.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00361">utilities.cpp:361</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a7abac7bb5b71e17382014c443244ad5c">PAULI_X</a></div><div class="ttdeci">@ PAULI_X</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga11c465ce1a5c238946a9e09d61c94c58"><div class="ttname"><a href="group__testutilities.html#ga11c465ce1a5c238946a9e09d61c94c58">setRandomPauliSum</a></div><div class="ttdeci">void setRandomPauliSum(qreal *coeffs, pauliOpType *codes, int numQubits, int numTerms)</div><div class="ttdoc">Populates the coeffs array with random qreals in (-5, 5), and populates codes with random Pauli codes...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l01054">utilities.cpp:1054</a></div></div>
<div class="ttc" id="astructQureg_html_ac2929e681d3d95591c18cf168dbbe4f0"><div class="ttname"><a href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">Qureg::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the state vector held by this process in the full state vector.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00217">QuEST.h:217</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gac9263a65c96a458b810b20baa81c5b94"><div class="ttname"><a href="group__testutilities.html#gac9263a65c96a458b810b20baa81c5b94">QVector</a></div><div class="ttdeci">std::vector&lt; qcomp &gt; QVector</div><div class="ttdoc">A complex vector, which can be zero-initialised with QVector(numAmps).</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8hpp_source.html#l00060">utilities.hpp:60</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a85c3f52533efe831bbe40b9a48602388"><div class="ttname"><a href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">DiagonalOp::imag</a></div><div class="ttdeci">qreal * imag</div><div class="ttdoc">The imaginary values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00191">QuEST.h:191</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga75966a02c618790c1de5f0102ab8398f"><div class="ttname"><a href="group__testutilities.html#ga75966a02c618790c1de5f0102ab8398f">setSubMatrix</a></div><div class="ttdeci">void setSubMatrix(QMatrix &amp;dest, QMatrix sub, size_t r, size_t c)</div><div class="ttdoc">Modifies dest by overwriting its submatrix (from top-left corner (r, c) to bottom-right corner (r + d...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00211">utilities.cpp:211</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gade0e7c37811a69f1c21c88c11943a19f"><div class="ttname"><a href="group__testutilities.html#gade0e7c37811a69f1c21c88c11943a19f">toQVector</a></div><div class="ttdeci">QVector toQVector(Qureg qureg)</div><div class="ttdoc">Returns an equal-size copy of the given state-vector qureg.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00938">utilities.cpp:938</a></div></div>
<div class="ttc" id="astructQureg_html_ab0ea0358482b62f43fdd781469607d97"><div class="ttname"><a href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">Qureg::numAmpsPerChunk</a></div><div class="ttdeci">long long int numAmpsPerChunk</div><div class="ttdoc">Number of probability amplitudes held in stateVec by this process In the non-MPI version,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00213">QuEST.h:213</a></div></div>
<div class="ttc" id="astructPauliHamil_html_ac1c6c9f6299cf83bbba88123216c3cac"><div class="ttname"><a href="structPauliHamil.html#ac1c6c9f6299cf83bbba88123216c3cac">PauliHamil::termCoeffs</a></div><div class="ttdeci">qreal * termCoeffs</div><div class="ttdoc">The coefficient of each Pauli product. This is a length numSumTerms array.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00164">QuEST.h:164</a></div></div>
<div class="ttc" id="agroup__type_html_gad863c5878a01051a2726ce94bf365428"><div class="ttname"><a href="group__type.html#gad863c5878a01051a2726ce94bf365428">qcomp</a></div><div class="ttdeci">#define qcomp</div></div>
<div class="ttc" id="astructPauliHamil_html_a4b8d38c403553c07ceddcd40c46ce6c8"><div class="ttname"><a href="structPauliHamil.html#a4b8d38c403553c07ceddcd40c46ce6c8">PauliHamil::pauliCodes</a></div><div class="ttdeci">enum pauliOpType * pauliCodes</div><div class="ttdoc">The Pauli operators acting on each qubit, flattened over every operator.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00162">QuEST.h:162</a></div></div>
<div class="ttc" id="agroup__debug_html_ga11448560006dd165128e404b54ebb2f7"><div class="ttname"><a href="group__debug.html#ga11448560006dd165128e404b54ebb2f7">copyStateToGPU</a></div><div class="ttdeci">void copyStateToGPU(Qureg qureg)</div><div class="ttdoc">In GPU mode, this copies the state-vector (or density matrix) from RAM (qureg.stateVec) to VRAM / GPU...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00036">QuEST_cpu.c:36</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a5131eeb67aafb4c19ac98270c3266742"><div class="ttname"><a href="structDiagonalOp.html#a5131eeb67aafb4c19ac98270c3266742">DiagonalOp::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdoc">The number of qubits this operator can act on (informing its size)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00181">QuEST.h:181</a></div></div>
<div class="ttc" id="astructPauliHamil_html_a737e46b40ef8990cf004d22eb9dbe2e4"><div class="ttname"><a href="structPauliHamil.html#a737e46b40ef8990cf004d22eb9dbe2e4">PauliHamil::numSumTerms</a></div><div class="ttdeci">int numSumTerms</div><div class="ttdoc">The number of terms in the weighted sum, or the number of Pauli products.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00166">QuEST.h:166</a></div></div>
<div class="ttc" id="agroup__type_html_gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd"><div class="ttname"><a href="group__type.html#gga1c703cf89629e4e9c7023cd402d67028a2c64a9aaee27f6bcfef894d159e759bd">PAULI_Y</a></div><div class="ttdeci">@ PAULI_Y</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00096">QuEST.h:96</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gae1d2eb70b50267f8186cbd53e300d94f"><div class="ttname"><a href="group__testutilities.html#gae1d2eb70b50267f8186cbd53e300d94f">getRandomStateVector</a></div><div class="ttdeci">QVector getRandomStateVector(int numQb)</div><div class="ttdoc">Returns a random numQb-length L2-normalised state-vector from an undisclosed distribution.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00453">utilities.cpp:453</a></div></div>
<div class="ttc" id="astructComplexMatrixN_html_a446e8a077597e4f76049d547df0c9738"><div class="ttname"><a href="structComplexMatrixN.html#a446e8a077597e4f76049d547df0c9738">ComplexMatrixN::real</a></div><div class="ttdeci">qreal ** real</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00139">QuEST.h:139</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gaa2e8b958e0cba07e01de9f91a5ce3c9c"><div class="ttname"><a href="group__testutilities.html#gaa2e8b958e0cba07e01de9f91a5ce3c9c">getRandomQMatrix</a></div><div class="ttdeci">QMatrix getRandomQMatrix(int dim)</div><div class="ttdoc">Returns a dim-by-dim complex matrix, where the real and imaginary value of each element are independe...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00368">utilities.cpp:368</a></div></div>
<div class="ttc" id="astructComplexMatrixN_html_afde13e469a3b4f179f45e53d1ec0a7cf"><div class="ttname"><a href="structComplexMatrixN.html#afde13e469a3b4f179f45e53d1ec0a7cf">ComplexMatrixN::imag</a></div><div class="ttdeci">qreal ** imag</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00140">QuEST.h:140</a></div></div>
<div class="ttc" id="astructQureg_html_a441e4cacef6bd17adb9813c7442d42fe"><div class="ttname"><a href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">Qureg::stateVec</a></div><div class="ttdeci">ComplexArray stateVec</div><div class="ttdoc">Computational state amplitudes - a subset thereof in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00222">QuEST.h:222</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a2c6eab631ef48b4978db026c98180eee"><div class="ttname"><a href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">DiagonalOp::numElemsPerChunk</a></div><div class="ttdeci">long long int numElemsPerChunk</div><div class="ttdoc">The number of the 2^numQubits amplitudes stored on each distributed node.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00183">QuEST.h:183</a></div></div>
<div class="ttc" id="astructQureg_html_acf78445e9435d09f44f0cc832c6aee79"><div class="ttname"><a href="structQureg.html#acf78445e9435d09f44f0cc832c6aee79">Qureg::isDensityMatrix</a></div><div class="ttdeci">int isDensityMatrix</div><div class="ttdoc">Whether this instance is a density-state representation.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00206">QuEST.h:206</a></div></div>
<div class="ttc" id="astructComplexMatrixN_html_a606f7afbc3f65a596bdca21cb43be6a8"><div class="ttname"><a href="structComplexMatrixN.html#a606f7afbc3f65a596bdca21cb43be6a8">ComplexMatrixN::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00138">QuEST.h:138</a></div></div>
<div class="ttc" id="autilities_8cpp_html_a5a70927d32d5ddd0f704767919d8ed01"><div class="ttname"><a href="utilities_8cpp.html#a5a70927d32d5ddd0f704767919d8ed01">updateIndices</a></div><div class="ttdeci">void updateIndices(int oldEl, int newEl, int *list1, int len1, int *list2, int len2)</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00276">utilities.cpp:276</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gabbc686f5f40eff22e08a2b2012ac4e41"><div class="ttname"><a href="group__testutilities.html#gabbc686f5f40eff22e08a2b2012ac4e41">QMatrix</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; qcomp &gt; &gt; QMatrix</div><div class="ttdoc">A complex square matrix.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8hpp_source.html#l00049">utilities.hpp:49</a></div></div>
<div class="ttc" id="astructPauliHamil_html_acb49fff0e3160ea1904c9ca34408b4e1"><div class="ttname"><a href="structPauliHamil.html#acb49fff0e3160ea1904c9ca34408b4e1">PauliHamil::numQubits</a></div><div class="ttdeci">int numQubits</div><div class="ttdoc">The number of qubits for which this Hamiltonian is defined.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00168">QuEST.h:168</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga5438455c2c8ecf5948ca22875313a590"><div class="ttname"><a href="group__testutilities.html#ga5438455c2c8ecf5948ca22875313a590">getNormalised</a></div><div class="ttdeci">QVector getNormalised(QVector vec)</div><div class="ttdoc">Returns an L2-normalised copy of vec, using Kahan summation for improved accuracy.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00431">utilities.cpp:431</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00208">QuEST.h:208</a></div></div>
<div class="ttc" id="astructQureg_html_adef4935cac95763c29164cf99b144ed4"><div class="ttname"><a href="structQureg.html#adef4935cac95763c29164cf99b144ed4">Qureg::numAmpsTotal</a></div><div class="ttdeci">long long int numAmpsTotal</div><div class="ttdoc">Total number of amplitudes, which are possibly distributed among machines.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00215">QuEST.h:215</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a1d66088bed235d524cd452b107694d5c"><div class="ttname"><a href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">DiagonalOp::real</a></div><div class="ttdeci">qreal * real</div><div class="ttdoc">The real values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00189">QuEST.h:189</a></div></div>
<div class="ttc" id="astructComplex_html_ab5b2e2eca02131fc74b289a83636cbe3"><div class="ttname"><a href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">Complex::real</a></div><div class="ttdeci">qreal real</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00105">QuEST.h:105</a></div></div>
<div class="ttc" id="agroup__testutilities_html_gac0c6339c28256f2aae86d443fae44455"><div class="ttname"><a href="group__testutilities.html#gac0c6339c28256f2aae86d443fae44455">getIdentityMatrix</a></div><div class="ttdeci">QMatrix getIdentityMatrix(size_t dim)</div><div class="ttdoc">Returns a dim-by-dim identity matrix.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00151">utilities.cpp:151</a></div></div>
<div class="ttc" id="aclassSequenceGenerator_html"><div class="ttname"><a href="classSequenceGenerator.html">SequenceGenerator</a></div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l01231">utilities.cpp:1231</a></div></div>
<div class="ttc" id="astructComplex_html_a84f5439aad0ef495efdd3b4c1c02d27e"><div class="ttname"><a href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">Complex::imag</a></div><div class="ttdeci">qreal imag</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00106">QuEST.h:106</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga50616e813b0d0aa4f8220785d780cdff"><div class="ttname"><a href="group__testutilities.html#ga50616e813b0d0aa4f8220785d780cdff">getKroneckerProduct</a></div><div class="ttdeci">QMatrix getKroneckerProduct(QMatrix a, QMatrix b)</div><div class="ttdoc">Returns the kronecker product of a and b, where a and b are square but possibly differently-sized com...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00169">utilities.cpp:169</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga6ccbb15b0f234e926be96a153181b63a"><div class="ttname"><a href="group__testutilities.html#ga6ccbb15b0f234e926be96a153181b63a">getZeroMatrix</a></div><div class="ttdeci">QMatrix getZeroMatrix(size_t dim)</div><div class="ttdoc">Returns a dim-by-dim square complex matrix, initialised to all zeroes.</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00143">utilities.cpp:143</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga27dc818709394cb31247e26850215f8a"><div class="ttname"><a href="group__testutilities.html#ga27dc818709394cb31247e26850215f8a">getRandomQVector</a></div><div class="ttdeci">QVector getRandomQVector(int dim)</div><div class="ttdoc">Returns a dim-length vector with random complex amplitudes in the square joining {-1-i,...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00420">utilities.cpp:420</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga45cc399adad2e2a67b0124851189fae5"><div class="ttname"><a href="group__testutilities.html#ga45cc399adad2e2a67b0124851189fae5">areEqual</a></div><div class="ttdeci">bool areEqual(QVector a, QVector b)</div><div class="ttdoc">Returns true if the absolute value of the difference between every amplitude in vectors a and b is le...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00387">utilities.cpp:387</a></div></div>
<div class="ttc" id="agroup__testutilities_html_ga731c2de4d491629d806a03e0aea2f3a3"><div class="ttname"><a href="group__testutilities.html#ga731c2de4d491629d806a03e0aea2f3a3">applyReferenceOp</a></div><div class="ttdeci">void applyReferenceOp(QVector &amp;state, int *ctrls, int numCtrls, int *targs, int numTargs, QMatrix op)</div><div class="ttdoc">Modifies the state-vector state to be the result of applying the multi-target operator matrix op,...</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00573">utilities.cpp:573</a></div></div>
<div class="ttc" id="autilities_8cpp_html_aba8ab64f4403dbfbd5a38902939535ff"><div class="ttname"><a href="utilities_8cpp.html#aba8ab64f4403dbfbd5a38902939535ff">DEMAND</a></div><div class="ttdeci">#define DEMAND(cond)</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00024">utilities.cpp:24</a></div></div>
<div class="ttc" id="autilities_8cpp_html_a3ab1cbd3fcacfb4f40e6898da03f8705"><div class="ttname"><a href="utilities_8cpp.html#a3ab1cbd3fcacfb4f40e6898da03f8705">macro_copyQMatrix</a></div><div class="ttdeci">#define macro_copyQMatrix(dest, src)</div><div class="ttdef"><b>Definition:</b> <a href="utilities_8cpp_source.html#l00838">utilities.cpp:838</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html"><div class="ttname"><a href="structComplexMatrix2.html">ComplexMatrix2</a></div><div class="ttdoc">Represents a 2x2 matrix of complex numbers.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00114">QuEST.h:114</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>
